Manage multiple languages in Android project with Google Spreadsheets
Nowadays, developing mobile apps that come with multiple languages is common. To support different languages in Android, the standard way is to create separate strings.xml
files for each language.
res/
values/
strings.xml # English
values-fr/
strings.xml # French
values-es/
strings.xml # Spain
If there is a request to replace a wording in the app that was different from the design. It will take time for developers to search and change the text, which may take 5 to 10 minutes for this simple work. Because no one can read the code but only the developer.
Solution
Google Spreadsheets is the platform that anyone can use, therefore the whole team can manage and make changes to this.
A sample sheet to manage multiple languages
Developers will refer to key strings column
Others such as content editors or translators can modify the content in language columns
Then it can be exported to separate XML files by writing a script for this automatic job. Now, anyone can manage the app content in a single place.
Export Spreadsheets to XML
We can write the script to export it in any language. In this example, I use python and pygsheets, since it comes with a suitable way to achieve this.
How to use
This was scripted with python 2.7, and requiring to install pygsheets
Follow this instruction to get authorization credentials to make Google APIs requests
Place the credentials in the same folder with exporter.py
Execute the command from the terminal
python exporter.py
If this is the first time, the permission request will appear, and we need to grant it.
Result
As a result, it will generate 3 XML files en.xml
, fr.xml
, es.xml
that declared in the sheet. Then developers just overwrite the new files in their project.