React-i18next: ADD hash to common.json file

Created on 25 Mar 2019  Â·  9Comments  Â·  Source: i18next/react-i18next

Problems I met
common.json is the file I used in my project with react-i18n
I want to add a different hash suffix like: common_sdfslkk.json to key it new, so that browsers can load new versions of this common.json file.
But if I add a suffix to the common.json file, the ns is changed to common_sdfslkk.
I don't know if it's right to say so.

What I need
I want to add a hash to the common.js file like: common_absddsldkf.json, but I still want to keep the namespace common.

Most helpful comment

What's the solution for this? I am now using create-react-app and can't find how to add hash to json filenames during development (npm start) and build (npm run build)

All 9 comments

You will need to change the loadPath (if using xhr) -> https://github.com/i18next/i18next-xhr-backend#backend-options

loadPath: '/locales/{{lng}}/{{ns}}-hash.json',

So I add a hash to common.json to common_asdgsd.json, the namespace is still common?

And I should edit the file by hand

Now if I add a hash to common.json to common_hash.json, the namespace is changed to common_hash. That's the problem.

yes - namespace will be interpolated to the {{ns}} -> so namespace will keep common

but honestly you do not need a hash...for what you need that...? there are cache-headers

Sometimes servers can't support Etag, and the new file common.json can't be loaded

Thank you very much!

did you find a solution

What's the solution for this? I am now using create-react-app and can't find how to add hash to json filenames during development (npm start) and build (npm run build)

Was this page helpful?
0 / 5 - 0 ratings