本文整理匯總了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);
}
示例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;
}
示例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()
}
示例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();
});
示例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);
}
示例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();
});
示例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);
}
示例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');
}
示例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);
}
示例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;
});