當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript moment.locale函數代碼示例

本文整理匯總了TypeScript中moment.locale函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript locale函數的具體用法?TypeScript locale怎麽用?TypeScript locale使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了locale函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: setLang

 setLang(lang: string, messages: any): void {
     // Only "creating" the language once
     if (moment.locale(lang) !== lang) {
         moment.defineLocale(lang, { relativeTime: messages } || {});
     }
     moment.locale(lang);
 }
開發者ID:dotCMS,項目名稱:core-web,代碼行數:7,代碼來源:format-date-service.ts

示例2:

export const setLocale = (locale: string) => {
  if (localeSet) {
    const previousLocal = moment.locale();
    console.warn(`Armstrong locale has already been set to ${previousLocal}, you probably only want to set it once!`);
  }

  moment.locale(locale);
  localeSet = true;
}
開發者ID:Rocketmakers,項目名稱:armstrong-react,代碼行數:9,代碼來源:config.ts

示例3: transformDate

export function transformDate(date) {

  const lang = i18nStore.lang
  const momentLang = moment.locale()

  if (lang === 'zh' && momentLang !== 'zh-cn') {
    moment.locale('zh-cn')
  } else if (momentLang !== lang) {
    moment.locale(lang)
  }
  return moment(date).fromNow()
}
開發者ID:doxiaodong,項目名稱:darlin-react,代碼行數:12,代碼來源:date.ts

示例4: async

    $ionicPlatform.ready( async () => {
        // configura locale do moment
        moment.locale( settings.locale );

        // configura rootScope
        $rootScope.isAndroid = ionic.Platform.isAndroid();  // Check platform of running device is android or not.
        $rootScope.isIOS = ionic.Platform.isIOS();          // Check platform of running device is ios or not.
        $rootScope.uiState = {
            loading: false,
            pendingRequests: 0,
            error: undefined
        };

        // We can now watch the trafficCop service to see when there are pending
        // HTTP requests that we're waiting for.
        let rootWatch = $rootScope.$watch( () => {
            $rootScope.uiState.pendingRequests = httpSnifferService.pending.all;
            $rootScope.uiState.loading = $rootScope.uiState.pendingRequests > 0;
            $rootScope.uiState.error = httpErrorSnifferService.error;
        } );

        $rootScope.$on( '$ionicView.beforeEnter', () => {
            httpErrorSnifferService.error = undefined;
        });

        // here is where the cleanup happens
        $rootScope.$on( '$destroy', () => rootWatch() );

        Keyboard.hideKeyboardAccessoryBar( true );
        Keyboard.disableScroll( true );

        // Check coarse location permissions
        cordovaPermissions.RequestCoarseLocationPermission();
    });
開發者ID:prodest,項目名稱:es-na-palma-da-mao-mobile,代碼行數:34,代碼來源:app.run.ts

示例5:

        (
            $sceProvider,
            $urlRouterProvider,
            $translateProvider,
            $urlMatcherFactoryProvider,
            $locationProvider,
            cfpLoadingBarProvider
        ) => {
            const preferred = "fi";

            $sceProvider.enabled(true);

            $urlRouterProvider.when("", "/" + preferred);
            $urlRouterProvider.when("/", "/" + preferred);
            $urlRouterProvider.otherwise(($injector, $location) => {
                $injector.get("virheService").setData({ path: $location.path() });
                $injector.get("$state").go("root.virhe");
            });

            $urlMatcherFactoryProvider.caseInsensitive(true);
            $urlMatcherFactoryProvider.strictMode(false);

            $translateProvider.useLoader("LokalisointiLoader");
            $translateProvider.preferredLanguage(preferred);
            $translateProvider.useSanitizeValueStrategy("escaped");

            $locationProvider.hashPrefix("");

            cfpLoadingBarProvider.parentSelector = "#loading-bar-container";
            cfpLoadingBarProvider.includeSpinner = true;
            cfpLoadingBarProvider.latencyThreshold = 100;

            moment.locale(preferred);
        }
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:34,代碼來源:app.ts

示例6: callback

        }).subscribe(res=>{
            let result = res.result;
            // $.extend(true, Abp, result);
            console.log('AbpUserConfiguration: %o', result);

            Abp.multiTenancy.setGlobal(result.multiTenancy);
            Abp.session.setGlobal(result.session);
            Abp.localization.setGlobal(result.localization);
            Abp.features.setGlobal(result.features);
            Abp.auth.setGlobal(result.auth);
            Abp.nav.setGlobal(result.nav);
            Abp.setting.setGlobal(result.setting);

            Abp.clock.setGloabl(result.clock);
            Abp.timing.setGloabl(result.timing);

            Abp.clock.provider = this.getCurrentClockProvider(result.clock.provider);

            moment.locale(Abp.localization.currentLanguage.name);

            if (Abp.clock.provider.supportsMultipleTimezone) {
                moment.tz.setDefault(Abp.timing.timeZoneInfo.iana.timeZoneId);
            }

            callback();
        });
開發者ID:staneee,項目名稱:ABPTemplateUI-ng-alain,代碼行數:26,代碼來源:AppPreBootstrap.ts

示例7: portalI18nConfig

function portalI18nConfig($translateProvider, $windowProvider) {
  'ngInject';

  $translateProvider.useLoader('i18nCustomLoader', {
    prefix: 'portal/i18n/',
    suffix: '.json'
  });

  $translateProvider
    .registerAvailableLanguageKeys( ["en", "fr", "pt-BR", "zh", "ru", "nl"], {
      "en*": "en",
      "fr*": "fr",
      "pt*": "pt-BR",
      "zh*": "zh",
      "ru*": "ru",
      "nl*": "nl",
      "*": "en"
      })
    .determinePreferredLanguage();
  $translateProvider.fallbackLanguage('en');
  $translateProvider.useSanitizeValueStrategy('escape');

  const locale = (window.navigator as any).userLanguage || window.navigator.language;
  moment.locale(locale);

}
開發者ID:gravitee-io,項目名稱:gravitee-management-webui,代碼行數:26,代碼來源:portal.i18n.ts

示例8: init

 init(lang:string) {
   moment.locale(lang);
   this.timestamp = moment().format();
   this.month = moment(this.timestamp).format('MMMM');
   this.date = moment(this.timestamp).format('D');
   this.day = moment(this.timestamp).format('dddd');
 }
開發者ID:qwb0920,項目名稱:MyDiary,代碼行數:7,代碼來源:calendar.ts

示例9: constructor

 constructor() {
   let lang = window.navigator['userLanguage'] || window.navigator.language || 'en';
   if (window.navigator['languages']) {
     lang = window.navigator['languages'][0];
   }
   console.info(`browser's language ${lang}`);
   moment.locale(lang);
 }
開發者ID:bchin22,項目名稱:metatron-discovery,代碼行數:8,代碼來源:app.module.ts

示例10:

    this.determineLang().then(lang => {
      this.translate.use(lang);
      this.translate.get("BACK_BUTTON").subscribe(back => {
        this.config.set("ios", "backButtonText", back);
      });

      moment.locale(lang);
      this.currentLang = lang;
    });
開發者ID:Bouzmine,項目名稱:metho,代碼行數:9,代碼來源:language.ts


注:本文中的moment.locale函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。