An app needs to load translation files (text type, JSON format) at runtime. And these translation files should be created by a program in dev runtime.
Requirement
Dev stage:
Write files to project directory at the dev runtime. This feature only work in dev stage, so it should be understand like write files to the computer of the developers. These files later will be bundled to app for prod usage.
Prod stage:
Read files from the bundle at the prod runtime. Assuming the files to read is already bundled to the app but not loaded yet and waiting for app load it.
hi there! you did not. there isn’t always someone around to help with questions about how to accomplish tasks, these are open ended questions that often are handled by other expo users. i’m sorry i don’t have a good answer to your question, but perhaps someone else who is on these forums will! if not, you may want to explore FileSystem to see how you can accomplish this in your app itself. it sounds like you also want something on the developer’s machine, not just the phone, i know of some tools like crowdin that help with this and should work fine with expo apps, but expo does not provide anything like this for you.
@wodin
Thank you for your suggestion, but unfortunately, the expo-localization is not enough to handle complex script.
@notbrent
Thank you for your assi
About the Fs, I think that is where I don’t understand most. It functions seem like download file from server, read files from local devices. I don’t know
There is no plug and play function that you can install and call in your app and it automagically works.
Your best hope, as I see it, is a workflow like this:
The dev/translation team provides the translations that you need in any format you would like to work with. Possibly, JSON is the easiest choice.
If you need to process the translations, you write a script in a language of your choice that does that, prior to build the app. Maybe, the easiest thing is to run this directly in nodejs, like this: node process_translation.js
The script will output the translations in any format that you want to use in your application. Outputting JS or JSON helps avoiding the need for further manual processing in the application.
The script either outputs directly in your app’s project folder, or you copy/move the outputted files to it.
In your app you import the translations and use them where you need. Again, bonus points for using JS/JSON as they are processed immediately upon import, or you may need some processing if you’re using XML or other formats.
instead of using expo build, you add a custom command in package.json, that runs your pre-processing script first:
yarn process_translation
runs the translation processing script only
yarn process_and_build build:ios
runs the translation processing script, and then runs the expo command with the parameters you provide after it (in this case, build:ios, but could be build:android or build:web, or even publish or other expo commands`