banff.nls package#
Submodules#
banff.nls.nls module#
Native Language Support (NLS).
Implement bilingual message support via gettext.
- banff.nls.nls.custom_gettext(a: str) str [source]#
Get gettext translation.
Implements custom gettext() function.
To be aliased as _() when used by other modules.
Uses the gettext instance corresponding to the active language.
- Why not use gettext.install()?
it goes against a tsunami of recommendations against modifying builtins
it plays poorly with intellisense
it makes the origin of the _() function untraceable to new developers
it may affect (or be affected by) 3rd party Python Code - installed _() can become broken (redefined, undefined) when running interactively.
Module contents#
Native Language Support (bilingual messages).
- class banff.nls.SupportedLanguage(*values)[source]#
Bases:
Enum
Languages supported by Native Language Support module.
Enums have the form <name> = <[list, of, values]> Users should refer to Enums by member-name, like SupportedLanguage.en.
- Internally, .value is used to associate a list of language tags with a supported language.
<name> - only use valid RFC1766 language tags <value> - should be a list of associated language tags
these tags should include both RFC1766 tags as well non RFC1766 tags observed in the wild (…on Windows)
- UNKNOWN = []#
- en = ['en', 'english']#
- fr = ['fr', 'french']#
- banff.nls.get_language() SupportedLanguage [source]#
Return the active language.
- banff.nls.set_language(lang: SupportedLanguage | None = None) None [source]#
Set the active language to lang, or determine language based on locale.
Specify a member of SupportedLanguage for lang.
The value set by this function will affect log message output. It may be referred to (via get_language()) by other modules in order to implement NLS.