Code | Language | Status |
---|---|---|
ar | Arabic | 🚧 Partial |
de | German | ✅ Complete |
el | Greek | ✅ Complete |
es | Spanish | ✅ Complete |
fr | French | ✅ Complete |
he | Hebrew | |
hr | Croatian | ✅ Complete |
it | Italian | ✅ Complete |
ja | Japanese | ✅ Complete |
ko | Korean | ✅ Complete |
nl | Dutch | ✅ Complete |
pt | Portugese | ✅ Complete |
ru | Russian | ✅ Complete |
th | Thai | ✅ Complete |
zh_Hans | Chinese (Simplified) | ✅ Complete |
zh_Hant | Chinese (Traditional) | ✅ Complete |
Localization is done with the Flask-Babel module.
Translated files live in translations/<Language Code>/LC_MESSAGES/messages.po
.
../messages.pot
file contains found English strings. This is the "master list" of strings needing translation.messages.po
files contain specific language translations.messages.mo
files are binary, compiled versions of the.po
files and should never be edited directly.
- Search source files and extract strings into a file
messages.pot
pybabel extract -F babel.cfg -o messages.pot --input-dirs=. --no-wrap
- Update
.po
translations with new strings.
pybabel update -i messages.pot -d translations --no-wrap
The .po
files are now ready for translation.
-
Download the new translations from Google Translator Toolkit. The file will be called
archive.zip
by default. (Note, you must download 2 or more languages to get a.zip
file.) -
In the
translations
directory, run:
python extract_po_files_from_gtt_zip.py ~/Downloads/archive.zip
This will grab the new .po
files for each langauge, and copy them to the correct place. Note this will overwrite the existing .po
files.
- Fix common errors:
python fix_po_files.py
- Compile translations into
.mo
files:
pybabel compile -f -d .
The -f
flag is needed to force the compile, since downloads from Google translator are always marked as 'fuzzy'
Note: .mo
files must committed in the repo in order for them to get on heroku.
- From repo root directory, run the website code to see new translations:
python main.py
pybabel init -i messages.pot -d translations -l <Language Code>
This will create the directory structure and initial .po
file.
Edit config/constants.py
and add the language-code under LANGUAGES
In the company-website
directory, run:
python main.py
And you should see the new language on the site.
If you get this error:
File "/Users/stan/Documents/Origin/company-website/lib/python2.7/site-packages/babel/messages/pofile.py", line 147, in _add_message
string = self.translations[0][1].denormalize()
IndexError: list index out of range
It most likely means that you have a %
in a msgstr
. These must be escaped as %%
.