next-ucap-messenger/projects/ucap-webmessenger-app/src/app/app-translate.module.ts

34 lines
991 B
TypeScript
Raw Normal View History

2019-09-18 06:02:21 +00:00
import { NgModule } from '@angular/core';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { UCAP_NATIVE_SERVICE, NativeService } from '@ucap-webmessenger/native';
export async function createTranslateLoader(nativeService: NativeService) {
// tslint:disable-next-line: variable-name
let _TranslateLoader;
_TranslateLoader = await import('@ucap-webmessenger/native-browser').then(
m => m.TranslateBrowserLoader
);
_TranslateLoader = await import('@ucap-webmessenger/native-electron').then(
m => m.TranslateElectronLoader
);
// return new TranslateBrowserLoader(nativeService, './assets/i18n/', '.json');
return new _TranslateLoader(nativeService, './assets/i18n/', '.json');
}
2019-09-18 06:02:21 +00:00
@NgModule({
imports: [
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: createTranslateLoader,
deps: [UCAP_NATIVE_SERVICE]
}
})
],
2019-09-18 06:02:21 +00:00
exports: []
})
export class AppTranslateModule {}