lib.translation

This library implements the translation support for the core and the plugins.

Note

Translations for the Administration Interface (Javascript) are not done through this API!

The translations for the webinterfaces are handled by this library, because the translations are done in Python and not on the html/Javascript side of the code.

The API is implemented through the following library:

This library implements the multi langugage support of SmartHomeNG.

lib.translation.initialize_translations(base_dir, default_language, fallback_language_order)[source]

Initialize the multi-language support

Parameters:
  • base_dir – Base directory of SmartHomeNG
  • default_language – language to be used for translations: ‘de’, ‘en’, ‘fr’, …
  • fallback_language_order – string with the fallback langauges (komma seperated)
lib.translation.set_default_language(language)[source]

Set language to be used for translations

Parameters:language – language to be used for translations: ‘de’, ‘en’, ‘fr’, …
lib.translation.set_fallback_language_order(language_order)[source]

Set fallback languages and their order

Fallback languages are used, if a translation for the selected default_language is not available

Parameters:language_order – string with the fallback langauges (komma seperated)
lib.translation.load_translations(translation_type='global', from_dir='bin', translation_id='global')[source]

Load global or plugin-specific translations from a locale.yaml file

Parameters:
  • translation_type – ‘global’ or ‘plugin’
  • from_dir – ‘bin’ (for global) or ‘plugins/<plugin name>’
Returns:

loaded translations as s dict

lib.translation.reload_translations()[source]

Reload translations for existing translation_ids - to test new translations without having to restart SmartHomeNG

lib.translation.translate(txt, additional_translations=None)[source]

Returns translated text

Parameters:
  • txt – TEXT TO TRANSLATE
  • additional_translations – ID for additional translations (if None, only global translations are used)
Returns:

Translated text