i18next / i18next-xhr-backend

[deprecated] can be replaced with i18next-http-backend
https://github.com/i18next/i18next-http-backend
MIT License
253 stars 75 forks source link

[React] Customized namespaces path #337

Open mwskwong opened 4 years ago

mwskwong commented 4 years ago

I know I can set the load path of namespaces like this:

{
    loadPath: "/locales/{{lng}}/{{ns}}.json"
}

In the case of React, it is located in public/locales.

However, can I set it to src/assets/locales?

jamuhl commented 4 years ago

Technically you can set it to whatever you like...your server just has to make the files available from that route...(be it webpack devserver or your production server...it's a http request and nothing fancy)

mwskwong commented 4 years ago

The problem is, after the compilation of create-react-app the actual path will be different. e.g. My logo which used to be in src/assets/images/logo.svg, now is located in static/media/logo.4c6bacf1.svg.

jamuhl commented 4 years ago

you can set the paths based on isProduction or not...

jamuhl commented 4 years ago

and you're talking about bundling...that's different from providing translations on a server...public/locales is nothing than webpack developer server hosting those files in public...

importing an svg is bundling the svg with your app...