[英]ngx translate not working on iOS device
我有一个 ionic 3 项目,我想使用 ngx translate。 它适用于浏览器和 iOS 模拟器,但不适用于真实设备(在 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 { }
我的文件在这里:
源代码/资产/i18n/DE.json
源代码/资产/i18n/EN.json
我是这样翻译的:
<ion-title translate>
{{ 'LOGIN.HEADER' | translate }}
</ion-title>
有人知道为什么它不会在设备上翻译吗?
可能有点晚了,但对于那些仍然遇到此问题的人,请执行以下任一解决方案:
npm install @ngx-translate/core
和npm install @ngx-translate/http-loader
更新到最新版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.