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:
{
"scripts": {
"start": "expo start",
"process_translation": "node process_translation.js",
"process_and_build": "node process_translation.js && expo"
}
}
And then, run the commands as:
-
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`