Angular Ionic 3 i18n在iOS WKWebview上的翻译

Angular Ionic 3 i18n在iOS WKWebview上的翻译,angular,typescript,cordova,ionic-framework,Angular,Typescript,Cordova,Ionic Framework,升级到WKWebview后,我无法从.json文件中获取翻译数据。它在浏览器中工作得非常好,但当我在设备中部署它时,它就不工作了 我的app.module.ts import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from "@angular/common/http"; import { TranslateModule, TranslateLoader } from "@ngx-translate/core"; imp

升级到WKWebview后,我无法从.json文件中获取翻译数据。它在浏览器中工作得非常好,但当我在设备中部署它时,它就不工作了

我的app.module.ts

import {
  HttpClientModule,
  HttpClient,
  HTTP_INTERCEPTORS
} from "@angular/common/http";
import { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
@NgModule({
  declarations: [
    MyApp,
    PopoverComponent,
    LimitToDirective,
    ImageModalPage,
    PaymentPage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    HttpModule,
    HttpClientModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: createTranslateLoader,
        deps: [HttpClient]
      }
    }),
    FormsModule,
    IonicImageLoader.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
   ...

  ],
  providers: [
    ...
  ]
})

export class AppModule {}

export function createTranslateLoader(http: HttpClient) {

  return new TranslateHttpLoader(http, "assets/i18n/", ".json");
}
转换初始化方法

 initTranslate() {
    this.translate.use("en");
  }
调用方法

<div class="primaryLabel">{{ "commons.version" | translate }}</div>
我的en.json文件

{
"commons": {
        "title": "XXXXX",
        "logout": "Logout",
        "confirmLogout": "Are you sure you want to logout ?",
        "currency": "SAR",
        "version": "Version",
        "updateProfile": "Update Profile",
        "faq": "FAQ"
    }
}

console.log(val)以“commons”的形式提供输出。

cordova插件wkwebview文件xhr
插件添加到项目中,它应该可以再次工作:

ionic cordova plugin add cordova-plugin-wkwebview-file-xhr

cordova插件wkwebview文件xhr
插件添加到您的项目中,它将再次工作:

ionic cordova plugin add cordova-plugin-wkwebview-file-xhr

你有办法吗?试试这个你有办法吗?试试这个