👽 add missing translation support

This commit is contained in:
Baptiste Lemoine 2019-10-01 16:39:29 +02:00
parent 90323c28c7
commit 91101f2326

View File

@ -27,9 +27,21 @@ import {VotingChoiceComponent} from './pages/voting-choice/voting-choice.compone
import {PasswordComponent} from './pages/password/password.component'; import {PasswordComponent} from './pages/password/password.component';
import {HomeComponent} from './pages/home/home.component'; import {HomeComponent} from './pages/home/home.component';
import {HttpClient, HttpClientModule} from '@angular/common/http'; import {HttpClient, HttpClientModule} from '@angular/common/http';
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core'; import {
MissingTranslationHandler,
MissingTranslationHandlerParams,
TranslateLoader,
TranslateModule,
TranslateService
} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader'; import {TranslateHttpLoader} from '@ngx-translate/http-loader';
export class MyMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) {
return 'some value';
}
}
registerLocaleData(localeFr, 'fr'); registerLocaleData(localeFr, 'fr');
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient) {
@ -64,6 +76,11 @@ export function HttpLoaderFactory(http: HttpClient) {
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
TranslateModule.forRoot({ TranslateModule.forRoot({
missingTranslationHandler: {
provide: MissingTranslationHandler,
useClass: MyMissingTranslationHandler,
},
useDefaultLang: false,
loader: { loader: {
provide: TranslateLoader, provide: TranslateLoader,
useFactory: HttpLoaderFactory, useFactory: HttpLoaderFactory,