ngx转换无法在iOS设备上运行 [英] ngx translate not working on iOS device

查看:76
本文介绍了ngx转换无法在iOS设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ionic 3项目,我想使用ngx转换. 它可以在浏览器和iOS模拟器中运行,但不能在真实设备上运行(已在iPhone SE,iOS 11.1上测试).

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

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 { }

我的文件在这里:

src/assets/i18n/DE.json

src/assets/i18n/DE.json

src/assets/i18n/EN.json

src/assets/i18n/EN.json

我这样翻译:

<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:

  • Update ngx-translate to the latest version by running npm install @ngx-translate/core & npm install @ngx-translate/http-loader
  • or follow this solution for a CustomLoader from https://github.com/ngx-translate/core/issues/642#issuecomment-344266618 by sebaferreras
  • or follow the solution on this post Ionic 3 Response with status: 0 for URL: null by CodeChanger

这篇关于ngx转换无法在iOS设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆