NDS Localisations
Contents:
- Typical i18n process - making changes to strings, deploying them on the server
- Typical i18n management tasks
- Writing localisation
- To set up and maintain the localisation infrastructure
- Adding new locales
- Additional notes...
- ISO notes and internationalization language code vs. lexicon/FST language code
- Currently supported localizations:
- Common error messages and troubleshooting
First we will look at typical maintenance tasks, and more detailed tasks will follow.
Typical i18n process - making changes to strings, deploying them on the server
Here is how you can expect to work:
- locally: make revisions to text
- locally: extract all strings (fab extract_strings)
- locally: check in in SVN
- on the server: svn up
- on the server: compile strings for the project (fab PROJNAME compile_strings)
Typical i18n management tasks
The fab script contains shortcuts for running all the following processes.
Recompiling changes to the localization
First ensure you are logged in as the user neahtta and are in the project directory.
cd ~/neahtta/
Then, update the new translations you already checked in locally:
svn up translations
Then, run the compile command for the specific project you are working on.
fab PROJNAME compile_strings
Where PROJNAME is a variable for the dictionary project, ex. sanit, baakoeh,
This will compile only the languages in this project, and avoids errors for
Recompiling changes to all localizations
The following command will compile everything, and may result in some errors if
fab compile_strings
Extracting strings due to code changes.
Sometimes you (or other maintainers) want to revise or enlarge
- $GTHOME/main/apps/dicts/nds/src/neahtta/templates
- $GTHOME/main/apps/dicts/nds/src/neahtta/configs/language_specific_rules/templates/
If in doubt, be careful, read documentation on a relevant django page.
If the source code has changed, this has likely resulted in line numbers being
First ensure you are in the project directory.
cd ~/neahtta/
Then, extract strings´, either for one specific dictionary project, or for all:
fab PROJNAME extract_strings fab extract_strings
Recompiling translations for production server
- log in to the server as the neahtta user
- switch to the project directory: cd ~/neahtta/
- write the command (again, exchange PROJNAME with your own dictionary):
fab PROJNAME compile_strings
If everything went good and there were no errors, continue, otherwise if you
Then, you need to restart the relevant services.
fab PROJNAME restart_service
(Where PROJNAME is a standin for the project name, e.g., baakoeh, valks, sanit, etc.)
Writing localisation
Translating the string to the localisation language
To write localisation (translate the interface to different languages) you
neahtta>find . -name "templates" -type d ./configs/language_specific_rules/templates ./templates
then you go to the specific directory, for instance, here:
configs/language_specific_rules/templates/
There you find your directory (follow your ISO code). Edit the lines
Then check in your changes, and then to update the server,
What if you are not satisfied with the content of the msgid (the original)?
The form of the msgid is not important (it is translated), but an msgid
Over each msgid there is a file reference, go there and correct
{% trans %}
before and a tag
{% endtrans %}
after the string to be translated. You thus change what you find between those two tags.
Then, you should compile new translations.po files. This is done on the NDS server.
fab PROJNAME compile_strings
Afterwards, check in the new .po files in translations/*/LC_MESSAGES/messages.po
Also read
To set up and maintain the localisation infrastructure
Internationalization (i18n) in Neahttadigisánit uses Flask-Babel
Translation strings are marked as they were in the Oahpa programs,
Marking translation strings in templates:
Running the commands
In order to run these commands locally on your own machine, you will need to
See: Developing NDS
Adding new locales
This comes in three main steps:
- Make sure .dat files exist
- Generate a .po file for the locale
- Check in the .po files
The easiest place to do this will be on the {gtdict} server, because the
See: Developing NDS
All further steps assume that you are doing this on gtdict, if you are
Dat files
Unknown locales such as crk and sma need to be defined somewhere. North Saami
Thus, for those we need to copy some files.
(1) Find out where they are with the following command, which will
$ fab find_babel <module 'babel' from 'path/to/.../site-packages/babel'>
(2) Change directories to the path printed in the above step:
$ cd path/to/.../site-packages/babel
(3) Change directories once more
$ cd localedata/
(4) Then, copy one dat file to the locale you wish to create (make a rational choice):
cp se.dat \ sma.dat
Thus the new locale will be able to be initialized with the init command below.
NB: If we were feeling more specific in this step, we could create a new
.po files:generate a message template for a new language.
First make sure that all the message files have been updated to the most recent
Now you can initialize a translation.
pybabel init -i translations/messages.pot -d translations -l LANG
Where LANG is the ISO code for the language project.
Additional notes...
Activating the virtual environment
If you do not see the environment enabled in the command prompt when you log in
source neahtta_env/bin/activate
If you do not see changes to the command prompt name, check which python to
Typically you should see something like:
(neahtta_env)[neahtta@gtdict ~]$
ISO notes and internationalization language code vs. lexicon/FST language code
Because most browsers report what language they use using the 2-character ISO
Currently supported localizations:
May be found in translations/, but for ease of finding out:
- fi Finnish
- kv (kpv) Komi (TODO: is this actually what komi users' browsers report?)
- lv (lav) Latvian
- mdf Moksha
- mhr Eastern Mari
- mrj Western Mari
- myv Erzya
- no (nob) Norwegian Bokmål
- ru Russian
- se (sme) North Saami
- sma South Saami
- sv Swedish
- yrk Nenets
Common error messages and troubleshooting
babel.core.UnknownLocaleError:unknown locale sms
This means that the locale directory is missing a .dat file for the locale.
catalog translations/sma/LC_MESSAGES/messages.po is marked as fuzzy, skipping
Babel marks things with #, fuzzy when it can't find the line in the source
Sometimes the first translation string in the catalogue will be marked fuzzy,