Classes | |
class | CSVLocale |
class | GettextLocale |
class | Locale |
Functions | |
def | get |
def | get_supported_locales |
def | load_gettext_translations |
def | load_translations |
def | set_default_locale |
Variables | |
string | _default_locale = "en_US" |
tuple | _supported_locales = frozenset([_default_locale]) |
dictionary | _translations = {} |
_use_gettext = False | |
dictionary | LOCALE_NAMES |
def tornado.locale.get | ( | locale_codes | ) |
Returns the closest match for the given locale codes. We iterate over all given locale codes in order. If we have a tight or a loose match for the code (e.g., "en" for "en_US"), we return the locale. Otherwise we move to the next code in the list. By default we return en_US if no translations are found for any of the specified locales. You can change the default locale with set_default_locale() below.
def tornado.locale.load_gettext_translations | ( | directory, | |
domain | |||
) |
Loads translations from gettext's locale tree Locale tree is similar to system's /usr/share/locale, like: {directory}/{lang}/LC_MESSAGES/{domain}.mo Three steps are required to have you app translated: 1. Generate POT translation file xgettext --language=Python --keyword=_:1,2 -d cyclone file1.py file2.html etc 2. Merge against existing POT file: msgmerge old.po cyclone.po > new.po 3. Compile: msgfmt cyclone.po -o {directory}/pt_BR/LC_MESSAGES/cyclone.mo
def tornado.locale.load_translations | ( | directory | ) |
def tornado.locale.set_default_locale | ( | code | ) |
Sets the default locale, used in get_closest_locale(). The default locale is assumed to be the language used for all strings in the system. The translations loaded from disk are mappings from the default locale to the destination locale. Consequently, you don't need to create a translation file for the default locale.
string tornado::locale::_default_locale = "en_US" |
tuple tornado::locale::_supported_locales = frozenset([_default_locale]) |
dictionary tornado::locale::_translations = {} |
tornado::locale::_use_gettext = False |
dictionary tornado::locale::LOCALE_NAMES |