2019-09-18 06:02:21 +00:00
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
|
|
|
|
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
|
|
|
|
2019-12-24 02:41:50 +00:00
|
|
|
import {
|
|
|
|
UCAP_NATIVE_SERVICE,
|
|
|
|
NativeService,
|
|
|
|
NativeType
|
|
|
|
} from '@ucap-webmessenger/native';
|
2019-09-24 00:03:36 +00:00
|
|
|
|
2019-12-18 04:44:26 +00:00
|
|
|
import { environment } from '../environments/environment';
|
|
|
|
|
|
|
|
export function createTranslateLoader(nativeService: NativeService) {
|
2019-12-24 02:41:50 +00:00
|
|
|
let prefix: string;
|
|
|
|
|
|
|
|
switch (nativeService.type()) {
|
|
|
|
case NativeType.Browser:
|
|
|
|
prefix = '/assets/i18n/';
|
|
|
|
break;
|
|
|
|
case NativeType.Electron:
|
|
|
|
prefix = environment.production
|
2020-02-13 10:44:11 +00:00
|
|
|
? // normal
|
|
|
|
'/dist/ucap-webmessenger-app/assets/i18n/'
|
2019-12-24 02:41:50 +00:00
|
|
|
: '/projects/ucap-webmessenger-app/src/assets/i18n/';
|
2020-02-13 10:44:11 +00:00
|
|
|
// installer > aws
|
|
|
|
// ? '/dist/ucap-webmessenger-app/assets/i18n/'
|
|
|
|
// : '/dist/ucap-webmessenger-app/assets/i18n/';
|
|
|
|
// vscode > prod
|
|
|
|
// ? '/projects/ucap-webmessenger-app/src/assets/i18n/'
|
|
|
|
// : '/projects/ucap-webmessenger-app/src/assets/i18n/';
|
2019-12-24 02:41:50 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nativeService.getTranslateLoader(prefix, '.json');
|
2019-09-24 00:03:36 +00:00
|
|
|
}
|
|
|
|
|
2019-09-18 06:02:21 +00:00
|
|
|
@NgModule({
|
2019-09-24 00:03:36 +00:00
|
|
|
imports: [
|
|
|
|
TranslateModule.forRoot({
|
|
|
|
loader: {
|
|
|
|
provide: TranslateLoader,
|
|
|
|
useFactory: createTranslateLoader,
|
|
|
|
deps: [UCAP_NATIVE_SERVICE]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
2019-09-18 06:02:21 +00:00
|
|
|
exports: []
|
|
|
|
})
|
|
|
|
export class AppTranslateModule {}
|