|Version 80 (modified by 10 years ago) ( diff ),|
Localization (L10N) of Trac
Trac uses Babel for localization. Trac trunk now contains the i18n framework and L10N files.
The Preferences ' Language panel can be used to select the language from the list of available translations, otherwise the web browsers' language preferences will be honored, if possible.
If you're only interested in using a localized version of Trac, then refer to the simpler 0.12/TracInstall instructions. The more complete installation instructions below are aimed at developers and translators.
Getting the Tool Chain
- Install Babel version [Babel:wiki:Download#LatestRelease:0.9.4 0.9.4]
Read the detailed installation instructions for Babel if you want to build it from source, but you should also be able to install it with a simple
easy_installor by using one of the packages in the Download page linked above.
- Likewise, install Genshi, from the Genshi:source:trunk (at least revision [G1072]).
- Get a svn checkout from the Trac trunk, e.g.
svn checkout http://svn.edgewall.org/repos/trac/trunk trac-0.12dev
Using Python tools
python setup.py extract_messages.
This will generate the catalog template file: source:trunk/trac/locale/messages.pot
You should never have to edit that file manually.
Note: this step is for committers only. If you're not a Trac svn committer, you have to use the available messages.pot, or bug us to update that file (though we do it on a regular basis).
python setup.py update_catalog.
This will regenerate the various string catalogs (
trac/locale/*_*/LC_MESSAGES/messages.po), preserving the previously translated strings and merging the new translations found in the messages.pot file. Translations that are no longer needed are commented out (
#~) and moved at the bottom of the .po file.
Usually, you will be interested in working on one locale only, so you can pass the
-loption to specify which catalog should be updated. For example:
python setup.py update_catalog -l nl_NL.
- Now, open your favorite editor and add or modify translations for the extracted strings in the messages.po file for your language.
- Once you're done, you should test your translations:
python setup.py update_catalog -lagain, for normalizing the manual edits. For example:
python setup.py update_catalog -l nl_NL.
This step is also quite useful for spotting the possible mistakes, like accidental changes of
msgidstrings. Look for lines beginning with
#~, they are indicative of such errors. Note that the comments corresponding to translations which are no longer present in the messages.pot file (as discussed in step 2. above) have been discarded by this second
python setup.py compile_catalog -f.
This will generate one compiled catalog (
message.mofile) for each (or each specified) messages.po file. You don't need to do anything with those files, they'll get installed automatically.
You will most probably need to use the force option (
-f) in order to compile catalogs marked "fuzzy". It is fine to have fuzzy translations but try to never contribute a translation still containing those markers, as they mean that a given translation has not been reviewed by a human but were machine generated. Fuzzy translations should be either cleared when they are wrong, or validated when they are correct, by removing the fuzzy tag or even the whole line iff fuzzy was the only keyword on that line
You can also use the
-loption here to specify the locale for which the messages.po has to be compiled.
python setup.py installfor installing Trac and locale data. Alternatively you can use
python setup.py developonce for all, if you want to be able to run Trac from your working copy.
Note that you could stop at step 3, but then you risk to submit incomplete or, worse, buggy messages.po files. Going through the 4th step will ensure a better quality standard. Finally, seeing your translations "live" in Trac is not only a great way to realize if the translation still makes sense once put in context, but also quite gratifying when you see that you picked the correct wording ;-)
The various catalog files (
messages.po) can be found in the repository under source:trunk/trac/locale. The
messages.pot is the template file from which the various locale-specific files get created.
If you need to create a catalog for a new locale (e.g. fr_CA), do:
$ ./setup.py init_catalog -l fr_CA
TODO add translation examples
The way to make up good translations of important terms is to discuss them before using everywhere. The easiest way to accomplish it is to set up wiki pages for different languages.
For the various languages there are already various tickets logged in which the work on them is tracked: No results
This is a way by which translators for the same language can coordinate their work.
- i18n infrastructure for Trac plugins (#7497)
- translation of wiki pages (#1513) and help pages (TracDev/Proposals/NewHelp)
- failure to start Trac (raw
NullTranslations instance has no attribute 'add'error) when no .mo file is available No results