localization Module

This module provides translation functionality.

The function to use for translation is _(string) to translate strings. When you use this in the .kv file, the translationss are automatically updated when the language is changed.

kniteditor.localization.change_language_to(new_language)[source]

Change the language to a language folder in the translations folder.

Parameters:new_language (str) – The language code to translate everything into. This code must be listed in list_languages().
Raises:ValueError – if new_language is not listed by list_languages()
kniteditor.localization.list_languages()[source]

Return a list of all supported languages.

Returns:a list of strings of language codes that can be passed as an argument to change_language_to()
Return type:list
kniteditor.localization.DEFAULT_LANGUAGE = 'en'

the default language to use

kniteditor.localization.current_language()[source]

Return the current language.

Returns:a language listed by list_languages()
Return type:str
kniteditor.localization.language_code_to_translation(language_code)[source]

Translate a language code.

Note that all language names are written in their language so that people can read them in their language.

Return type:

str

Returns:

the translated language

Parameters:

language_code (str) – a language code from list_languages()

Raises:

Note

this operation can be reversed by translation_to_language_code()

c2 = language_code_to_translation(language_code_to_translation(c1))
assert c1 == c2
kniteditor.localization.translation_to_language_code(translated_language_code)[source]

Translate a language back to a langugage code.

Parameters:translated_language_code (str) – a language returned by language_code_to_translation()
Return type:str
Returns:a language code in list_languages()
Raises:ValueError – if this translation is not known
kniteditor.localization.change_language_to_translated(new_language)[source]

Set the language to a translated language name.

Parameters:new_language (str) – a language form list_translated_languages()
Raises:ValueError – if new_language is not listed in list_translated_languages()
kniteditor.localization.current_translated_language()[source]

The current language as a translated string.

Return type:str
Returns:the translated version of the current language
kniteditor.localization.list_translated_languages()[source]

Return a list of translated language names.

Return type:list
Returns:a list of translated language names