i18next / i18next-http-backend

i18next-http-backend is a backend layer for i18next using in Node.js, in the browser and for Deno.
MIT License
443 stars 67 forks source link

Fails completely with file:// URLs #100

Closed tcobbs-bentley closed 1 year ago

tcobbs-bentley commented 1 year ago

🐛 Bug Report

This package is presented as a replacement for i18next-xhr-backend. Unfortunately, it omits support for one use case that worked fine with i18next-shr-backend: the use of file:// URLs for the localized resources in an environment that contains the fetch API. In that case, it tries to use the fetch API, and the fetch API simply states that file:// URLs are not supported, and so everything fails. The file:// URLs worked fine with i18next-xhr-backend.

To Reproduce

Set up a project that uses file:// URLs for its i18n json files. Make sure the fetch API is present at run-time.

I apologize for not providing better steps, but my project isn't something that I can share. I can say that it is an Android app that loads a React web app into a WebView using a file:// URL for the top-level URL for the web app, and hence all of the i18n json files also use file:// URLs.

My error messages in the Android debug console end up looking like this:

I/chromium: [INFO:CONSOLE(411487)] "Fetch API cannot load file:///android_asset/ITMApplication/frontend/locales/en-US/iModelJs.json. URL scheme "file" is not supported.", source: file:///android_asset/ITMApplication/frontend/static/js/0.e152a96b.chunk.js (411487)

Expected behavior

i18n should still work when using file:// URLs when loading json localization files.

Your Environment

adrai commented 1 year ago

never used it that way... v2.0.1 may work