简体   繁体   中英

ngx translate not working on iOS device

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?

it might be a bit late, but for those who still experience this issue please do either of the following solutions:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM