member_webapp/src/app/app-l10n.module.ts

58 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-04-06 15:59:49 +09:00
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { BrowserModule, Title } from '@angular/platform-browser';
import {
L10nConfig,
L10nLoader,
LocalizationModule,
LocaleValidationModule,
StorageStrategy,
ProviderType
} from 'angular-l10n';
const l10nConfig: L10nConfig = {
locale: {
languages: [
{ code: 'en', dir: 'ltr' },
{ code: 'kr', dir: 'ltr' },
],
defaultLocale: { languageCode: 'en', countryCode: 'US' },
storage: StorageStrategy.Cookie,
cookieExpiration: 30
},
translation: {
providers: [
{ type: ProviderType.Static, prefix: './assets/translations/of-' }
],
caching: true,
composedKeySeparator: '.',
missingValue: 'No key',
i18nPlural: true
}
};
export function initL10n(l10nLoader: L10nLoader): Function {
return () => l10nLoader.load();
}
@NgModule({
imports: [
LocalizationModule.forRoot(l10nConfig),
LocaleValidationModule.forRoot()
],
exports: [
LocalizationModule,
LocaleValidationModule,
],
providers: [
Title,
{
provide: APP_INITIALIZER,
useFactory: initL10n,
deps: [L10nLoader],
multi: true
}
],
})
export class AppL10NModule { }