mirror of
https://github.com/ceph/ceph
synced 2024-12-29 06:52:35 +00:00
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:
parent
69bca2437d
commit
d0a8ee9bc6
@ -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]
|
||||
|
@ -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 };
|
||||
|
Loading…
Reference in New Issue
Block a user