Package peppy :: Package i18n
[frames] | no frames]

Package i18n

Localization utilities for peppy

The i18n concepts here are a combination of the locale support from TaskCoach<http://www.taskcoach.org and Editra<http://www.editra.org.

From TaskCoach I've borrowed the idea that message catalogs are stored in python dictionaries, not gettext .po files. Gettext .po files are used to create the message catalogs and in Launchpad Translations, but they are then run through a preprocessor to generate the python dicts that are distributed with the program.

From Editra I've borrowed some code in the createTranslationMap method and the LangListCombo control.

Submodules

Classes
  LocaleDetails
Storage for locale info.
  LangListCombo
Combines a langlist and a BitmapComboBox
Functions
 
createTranslationMap(loc_list)
Create a mapping from catalog name to locale details.
 
getTranslationMap()
Convenience function to create the translation map and description map
 
importCatalog(catalog)
Attempt to load the message catalog.
Variables
  supplied_translations = ['en_US', 'da', 'fr_FR', 'ru_RU', 'it_...
  translation_map = None
  description_map = None
Function Details

createTranslationMap(loc_list)

 

Create a mapping from catalog name to locale details.

Scans the wx locale data to determine the wx language ID and plain-text description that can be used in the user interface to choose the language.

The catalog names are passed in as a list, and may contain either the language and country, or just the language. If it's just the language, the first match in the wx language list is returned. On my machine, for instance, there is no match for only the "ru" locale -- it's either 'ru_RU' for Russia or 'ru_UA' for the Ukrainian dialect of Russian. So, because "ru_RU" appears first in the list, that will be used for "ru".

Heavily modified from the Editra source.

getTranslationMap()

 

Convenience function to create the translation map and description map

The translation map is generated by createTranslationMap, and is then used to create another mapping from the user-friendly name of the locale to the catalog name.

importCatalog(catalog)

 

Attempt to load the message catalog.

Message catalogs used in peppy are dictionaries generated from gettext .po files. The .po files are pre-compiled into the dictionaries and stored in modules in this directory named as the message catalog name. If the import of the catalog succeeds, the dict and its encoding will be returned; otherwise a blank dict is returned.


Variables Details

supplied_translations

Value:
['en_US',
 'da',
 'fr_FR',
 'ru_RU',
 'it_IT',
 'es_ES',
 'de_DE',
 'zh_CN',
...