Reputation: 58
How i can load translations json files in RN? In browser i can use fetch and XHR, but in application it must be some kind of file system acces with copy translations to ./android/app/src/main/assets/ folder?
Upvotes: 2
Views: 1490
Reputation: 4498
We load the using the xhr-backend. Not yet had the need to cache those on asyncStorage but doing so would be rather easy - copy of the https://github.com/i18next/i18next-localStorage-cache using asyncStorage
Or add them using i18next.addResourceBundle: https://www.i18next.com/api.html#addresourcebundle
Or use a webpack bundler: https://github.com/atroo/i18next-resource-store-loader
But a loader from filesystem of phone would be great too, not yet know if someone built that.
Upvotes: 2