Python script that uses Google Translation service to localize Android strings and validate positional parameters for correctness
Table of Contents
This is a python module to automatically make string.xml file for different languages for Android
For using Google translation API, you have to setup the Google translation api and then download service account private key and export the variable to the path of the key at environment variable name GOOGLE_APPLICATION_SERVICE_ACCOUNT_CREDENTIALS_FOR_TRANSLATION
This script has the following arguments:
-
-h,--helpshow this help message and exit -
-o,Ospecify the absolute path of the output folder -
-i,Ispecify the absolute path of the input file -
-lang,LANGspecify the comma-separated languages, ex: -lang 'en,it' -
-fforce to redo the translation of all the key values, default = False -
-p,POOLset the number of process pool to use, default = 5 -
-venable the debug logs
python3 gtranslate.py [-h] [-o O] [-i I] [-lang LANG] [-f] [-p POOL] [-v]e.g.
python3 gtranslate.py -i <input strings.xml path> -o <output folder where all values-<lang_code>/strings.xml will be upadated/created> -lang 'ar,de,es,fr,hi,it,ja,ko,pl,pt-rPT,ru,tl,vi,zh-rCN,zh-rTW' -vIn the output folder, you should have already copied strings.xml in values-<lang_code>/strings.xml so that only new keys will be translated.
This is a python module to verify the same number of positional arguments, missing translation, warning characters(e.g., &, ..., -, --) and wrong xml escaping
This script has the following arguments:
-
-h,--helpshow this help message and exit -
-o,Ospecify the absolute path of the output folder -
-i,Ispecify the absolute path of the input file -
-lang,LANGspecify the comma-separated languages, ex: -lang 'en,it' -
-p,POOLset the number of process pool to use, default = 5 -
-venable the debug logs
python3 validate.py [-h] [-o O] [-i I] [-lang LANG] [-p POOL] [-v]e.g.
python3 validate.py -i <input strings.xml path> -o <output folder where all values-<lang_code>/strings.xml will be upadated/created> -lang 'ar,de,es,fr,hi,it,ja,ko,pl,pt-rPT,ru,tl,vi,zh-rCN,zh-rTW' -v