I have an ionic 3 project and I want to use ngx translate. It works in the browser and the iOS simulator but not on a real device (tested on iPhone SE, iOS 11.1).
app.module.ts
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpClient, HttpClientModule } from '@angular/common/http';
export function HttpLoaderFactory (http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
[...],
imports: [
[...]
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (HttpLoaderFactory),
deps: [HttpClient]
}
})
],
[...]
})
export class AppModule { }
My files are here:
src/assets/i18n/DE.json
src/assets/i18n/EN.json
I translate it this way:
<ion-title translate>
{{ 'LOGIN.HEADER' | translate }}
</ion-title>
Does someone know why it won't be translated on a device?
WKWebView
? – sebaferreras<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
to my config.xml, but it didn't solve the problem. – chocolate cakeWkWebView
sinceUiWebView
will be deprecated – sebaferreras.map
does not exist on typeObservable<string>
. So, I couldn't really test it. I tried to rewrite it without success. Then I just wrotereturn this.http.get(
./assets/i18n/EN.json);
From this moment it worked and it also with my old implementation (+ I changed the language file name to lowercase (en.json, de.json) what I have tried already so many times before). So, I don't really know why, but it seems to work now. Thanks for your help! – chocolate cake