-
Notifications
You must be signed in to change notification settings - Fork 156
GeoDa Internationalization Project
GeoDa Internationalization (I18n) and Localization(L10n) project aims to provide an online tool that GeoDa users could help to translate the GeoDa UI to different languages.
For crowdsourcing, we use Google Spreadsheet with the public address here. Anyone can access this spreadsheet, and edit the items of each translation.
Before every GeoDa release, a program will be used to download the spreadsheet, extract edits for verification, and merge valid edits into GeoDa's language packages.
Please visit Google Sheet here. You can click on the sheet that you want to help to translate (see the table below)
Language | Sheet Name |
---|---|
Spanish | es |
中文 | zh_CN |
- Column A contains the English messages that need to be translated (not editable)
- Column B you can contribute by inputting proper translation in each cell
- Column C you can input your email, GitHub alias, etc. so we can include your name in GeoDa's contribution list
Note
- Empty spaces should be reserved in translation
- Placeholders (no need to translate): %d %s %f \t \n
- Symbols (no need to translate): > < == =
One of the most classic tools for I18n and L10n is a Unix tool called Gettext, which is used in this project. There are three file types you usually deal with while working with Gettext. PO (Portable Object), MO (Machine Object) files and POT (PO Template) file.
I18n
|
├──lang
| ├──config.ini
| ├── es
│ | └── geoda.mo
| └── zh_CN
│ └── geoda.mo
|
├──profile
│ ├── es.mo
│ └── zh_CN.po
|
└── geoda.pot
The related files can be found under geoda_source_dir/internationalization.
The above example shows the directory name (e.g. es/
, zh_CN/
following the Locale Code
, which is simply a code that identifies one version of a language. It’s defined following the ISO 639-1 and ISO 3166-1 alpha-2 specs: two lower-case letters for the language, optionally followed by an underscore and two upper-case letters identifying the country or regional code.
Before every GeoDa release, please follow the procedures below to create language packages for GeoDa.
To create a geoda.pot file, one can run the shell script under geoda_source_dir/internationalzation directory:
./1_create_geoda_pot.sh
This script will go through all the *.cpp and *.h files under geoda_source_dir directory, and extract the strings coded in _()
macro.
# 1_create_geoda_pot.sh
# the first part will use find() command to find _() strings from
find .. \( -name '*.cpp' -o -name '*.h' \) -not -path "../BuildTools/*" | xargs xgettext -d geoda -s --keyword=_ -p ./ -o geoda.pot
There are also strings defined in various xrc files (e.g. menu.xrc
, dialogs.xrc
etc). There is a python script gen_po_from_xrc.py
that can be used to create a xrc.pot
file.
python3 2_gen_po_from_xrc.py
Get new items by comparing existing PO file (e.g. zh_CN.po, specified using argument --input) with new POT files (geoda.pot and xrc.pot extracted from source code). New msgid with empty msgstr will be written into a new PO file specified by argument --output
python3 3_get_diff_PO.py ./geoda.pot ./xrc.pot --input ./pofiles/zh_CN.po --output ./pofiles/new_zh_CN.po
python po2csv.py ./pofiles/new_zh_CN.po ./new_zh_CN.csv
The following section describes how the Google spreadsheet is prepared. They should NOT be executed again.
Update existing PO file (e.g. zh_CN.po, specified using argument --input) using POT files (geoda.pot and xrc.pot extracted from source code. New msgid with empty msgstr will be added into existing PO file and saved into a new file specified by argument --output')
python3 3_updatePO.py ./geoda.pot ./xrc.pot --input ./pofiles/es.po --output ./pofiles/new_es.po
python3 3_updatePO.py ./geoda.pot ./xrc.pot --input ./pofiles/zh_CN.po --output ./pofiles/new_zh_CN.po
python3 3_updatePO.py ./geoda.pot ./xrc.pot --input ./pofiles/de.po --output ./pofiles/new_de.po
python3 3_updatePO.py ./geoda.pot ./xrc.pot --input ./pofiles/jp.po --output ./pofiles/new_jp.po
Generate a .CSV file from .PO file, so that we can upload it to Google Spreadsheet.
Please not the .CSV file uses the character ` to separate values.
python po2csv.py ./pofiles/new_es.po ./es.csv
python po2csv.py ./pofiles/new_zh_CN.po ./zh_CN.csv
python po2csv.py ./pofiles/new_jp.po ./jp.csv
python po2csv.py ./pofiles/new_de.po ./de.csv
msgfmt ./pofiles/es.po -o ./lang/es/GeoDa.mo