mgr/dashboard: Provide TRANSLATIONS directly in app.module.ts

Remove LOCALE_ID from provide list, since this is now defined during build.

Signed-off-by: Tiago Melo <tmelo@suse.com>
This commit is contained in:
Tiago Melo 2019-10-02 10:51:07 +00:00 committed by Ricardo Dias
parent 69bca2437d
commit d0a8ee9bc6
No known key found for this signature in database
GPG Key ID: 74390C579BD37B68
2 changed files with 20 additions and 25 deletions

View File

@ -1,5 +1,11 @@
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import {
ErrorHandler,
LOCALE_ID,
NgModule,
TRANSLATIONS,
TRANSLATIONS_FORMAT
} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@ -18,7 +24,6 @@ import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CephModule } from './ceph/ceph.module';
import { CoreModule } from './core/core.module';
import { i18nProviders } from './locale.helper';
import { ApiInterceptorService } from './shared/services/api-interceptor.service';
import { JsErrorHandler } from './shared/services/js-error-handler.service';
import { SharedModule } from './shared/shared.module';
@ -66,7 +71,19 @@ export function jwtTokenGetter() {
useClass: ApiInterceptorService,
multi: true
},
i18nProviders,
{
provide: TRANSLATIONS,
useFactory: (locale) => {
locale = locale || 'en-US';
try {
return require(`raw-loader!locale/messages.${locale}.xlf`).default;
} catch (error) {
return [];
}
},
deps: [LOCALE_ID]
},
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' },
I18n
],
bootstrap: [AppComponent]

View File

@ -1,7 +1,3 @@
import { LOCALE_ID, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core';
declare const require;
export class LocaleHelper {
static getBrowserLang(): string {
const lang = navigator.language;
@ -45,21 +41,3 @@ export class LocaleHelper {
}
}
const i18nProviders = [
{ provide: LOCALE_ID, useValue: LocaleHelper.getLocale() },
{
provide: TRANSLATIONS,
useFactory: (locale) => {
locale = locale || 'en-US';
try {
return require(`raw-loader!locale/messages.${locale}.xlf`).default;
} catch (error) {
return [];
}
},
deps: [LOCALE_ID]
},
{ provide: TRANSLATIONS_FORMAT, useValue: 'xlf' }
];
export { i18nProviders };