ngx-translate / core

The internationalization (i18n) library for Angular
MIT License
4.53k stars 578 forks source link

When the browser directly accesses the ionic3 project, the load language package file occurs across domain issues. #812

Closed 15380831711 closed 6 years ago

15380831711 commented 6 years ago

The error message: XMLHttpRequest cannot load file:///D:/project/2017/youPai/front/youpai/www/assets/i18n/en.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. Is there a solution? It's not available in the WKWebView.

CodeAndWeb commented 6 years ago

I am not familiar with ionic3... sorry. And it's hard to help you without at least some example code. Maybe you should ask in the ionic forum about this.

The question is: Why is it trying to access the absolute path with file://? Is there a way around this? https://github.com/oracle/cordova-plugin-wkwebview-file-xhr might be an option for you.

You can also just import the translations and use translate.setTranslation() to set them.