This is the script that translates an array of english written texts to supported text and append the results to Localizable.strings file.
install python3 if not already installed
brew install python3
there are 2 arguments
-
-i
or--input_dir
: Base input directory that the holds all the localizable folders . Do not insertlproj
folder here. pass the folder that holds alllproj
folders inside it. -
-l
or--list
: list of strings that to be translated. This will be the key valur in your localizable.strings file. Make sure to enter in English. every key word must be seperated with space . multiple words must be inside a'
character.
run the script like so :
python3 translate.py -i [PATH_TO_FOLDER_THAT_HOLDS_LPROJ_FOLDERS] -l [TRANSLATION_TEXT]
eg:
python3 translate.py -i ~/Desktop/project/Localizations -l 'Hello World' Widgets 'UI Design'
and now script will make request to google translate itself, and write results to that language Localizable.strings
file.
- Arabic,
- Belarusian,
- Cambodian,
- Czech,
- Chinese (Simplified),
- Chinese (Traditional),
- Dutch,
- English,
- French,
- German,
- Hebrew,
- Hungarian,
- Indonesian,
- Italian,
- Japanese,
- Korean,
- Malay,
- Norwegian,
- Portuguese,
- Portuguese (brazilian),
- Polish,
- Russian,
- Romanian,
- Thai,
- Turkish,
- Swedish,
- Spanish,
- Spanish (latin america)
- Ukrainian,
- Vietnamese,
open translate.py in any code editor. inside you will find a tuple array named LANGS
just add your value to the end of array. Tuple's first item must be lproj folder name without lproj, second will be the google translate language key. you can find this value inside google translate url parameters
https://translate.google.com/?sl=de&tl=ko&op=translate
sl=de |
start language de which is German |
tl=ko |
target language ko which is Korean |
eg:
korean localizations are represented as ko.lproj
in Xcode
korean represented as ko
in url parameter of google translate
so if you want to add korean append this line to LANGS array
("ko" , "ko")
happy coding