在Ionic 4中的服务器上部署浏览器后,ngx-translate问题

时间:2020-02-17 12:00:52

标签: ionic-framework web ionic4 ngx-translate

每个人我都有关于ngx翻译的问题。当我用“离子服务”检查翻译时,一切正常。但是,当我运行“ ionic cordova构建浏览器”并上传到服务器时,它会生成

"GET http://xxxxx.xxxxxxxx.xxxx/assets/i18n/en.json 404 (Not Found)"

http错误响应

"Http failure response for http://xxxxx.xxxxxxxx.xxxx/assets/i18n/en.json: 404 Not Found"

app.modlue.ts

import {TranslateLoader, TranslateModule} from '@ngx-translate/core';


TranslateModule.forRoot({
  loader: {
      provide: TranslateLoader,
      useFactory: HttpLoaderFactory,
      deps: [HttpClient]
  }
})

export function HttpLoaderFactory(http: HttpClient) {
 return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

我还设置了

translate.setDefaultLang((localStorage.getItem('LANG')) ? localStorage.getItem('LANG') : 'en');

但相同的错误。请帮助我。

0 个答案:

没有答案