Auto translate .strings
localization files into multiple languages for use in an XCode project.
- Add keys and translations in the origin language in a
.strings
file pip3 install googletrans==4.0.0-rc1
for Google Translatepip3 install --upgrade deepl
for DeepLpython3 strings_translate.py
usage: strings_translate.py [-h] [-t T] [-a A] [-f F] [-o O] [-d D] [-v V]
optional arguments:
-h, --help show this help message
-t T set translation service. Possible values: deepl, google (default). For DeepL an api key must be provided with -a
-a A set DeepL api token
-f F set the path to the origin .strings file to read keys and base translations from, default is Localizable.strings
-o O set the language that is used in the origin .strings file, default is english
-d D set the destination path for the exported translations, defaults to output
-v V Verbose
NOTE: Failed translations are not copied over to the output directory.
python3 strings_translate.py -f /some/path/to/Localizable.strings
To use DeepL you need to set the translation service to deepl and add you DeepL api token
python3 strings_translate.py -t deepl -a AUTH_TOKEN_HERE
use -o
to set your origin language,
for example python3 strings_translate.py -o de
when your base translations are in German,
by default the origin language is set to english
edit LanguageCodes.txt
to add or remove languages you want to translate. Make sure to use the correct language codes for each service.
After translating your strings, you can add them to your existing XCode project. The new strings will be inserted to your existing localzation files.
python3 strings_add.py -d /some/path/to/project/
usage: strings_add.py [-h] [-s S] [-d D] [-f F]
optional arguments:
-h, --help show this help message and exit
-s S path to source localization files, default is output
-d D path to target folder in your project where the strings should be inserted
-f F file name of the .strings file, default is Localizable.strings
NOTE: Currently there is no check if a key already exists.