Classes | |
| class | _TranslationCache |
| class | _TranslationsCacheData |
Functions | |
| dict[str, dict[str, Any]] | _async_get_component_strings (HomeAssistant hass, Iterable[str] languages, set[str] components, dict[str, Integration] integrations) |
| _TranslationCache | _async_get_translations_cache (HomeAssistant hass) |
| dict[str, dict[str, Any]] | _load_translations_files_by_language (dict[str, dict[str, pathlib.Path]] translation_files) |
| dict[str, str] | async_get_cached_translations (HomeAssistant hass, str language, str category, str|None integration=None) |
| str | async_get_exception_message (str translation_domain, str translation_key, dict[str, str]|None translation_placeholders=None) |
| dict[str, str] | async_get_translations (HomeAssistant hass, str language, str category, Iterable[str]|None integrations=None, bool|None config_flow=None) |
| None | async_load_integrations (HomeAssistant hass, set[str] integrations) |
| None | async_setup (HomeAssistant hass) |
| str | async_translate_state (HomeAssistant hass, str state, str domain, str|None platform, str|None translation_key, str|None device_class) |
| bool | async_translations_loaded (HomeAssistant hass, set[str] components) |
| dict[str, dict[str, Any]|str] | build_resources (dict[str, dict[str, dict[str, Any]|str]] translation_strings, set[str] components, str category) |
| dict[str, str] | recursive_flatten (str prefix, dict[str, dict[str, Any]|str] data) |
Variables | |
| _LOGGER = logging.getLogger(__name__) | |
| string | LOCALE_EN = "en" |
| string | TRANSLATION_FLATTEN_CACHE = "translation_flatten_cache" |
Translation string lookup helpers.
|
private |
Load translations.
Definition at line 89 of file translation.py.
|
private |
Return the translation cache.
Definition at line 380 of file translation.py.
|
private |
Load and parse translation.json files.
Definition at line 49 of file translation.py.
| dict[str, str] homeassistant.helpers.translation.async_get_cached_translations | ( | HomeAssistant | hass, |
| str | language, | ||
| str | category, | ||
| str | None | integration = None |
||
| ) |
Return all cached backend translations. If integration is specified, return translations for it. Otherwise, default to all loaded integrations.
Definition at line 362 of file translation.py.
| str homeassistant.helpers.translation.async_get_exception_message | ( | str | translation_domain, |
| str | translation_key, | ||
| dict[str, str] | None | translation_placeholders = None |
||
| ) |
Return a translated exception message. Defaults to English, requires translations to already be cached.
Definition at line 434 of file translation.py.
| dict[str, str] homeassistant.helpers.translation.async_get_translations | ( | HomeAssistant | hass, |
| str | language, | ||
| str | category, | ||
| Iterable[str] | None | integrations = None, |
||
| bool | None | config_flow = None |
||
| ) |
Return all backend translations. If integration is specified, load it for that one. Otherwise, default to loaded integrations combined with config flow integrations if config_flow is true.
Definition at line 336 of file translation.py.
| None homeassistant.helpers.translation.async_load_integrations | ( | HomeAssistant | hass, |
| set[str] | integrations | ||
| ) |
Load translations for integrations.
Definition at line 418 of file translation.py.
| None homeassistant.helpers.translation.async_setup | ( | HomeAssistant | hass | ) |
Create translation cache and register listeners for translation loaders. Listeners load translations for every loaded component and after config change.
Definition at line 386 of file translation.py.
| str homeassistant.helpers.translation.async_translate_state | ( | HomeAssistant | hass, |
| str | state, | ||
| str | domain, | ||
| str | None | platform, | ||
| str | None | translation_key, | ||
| str | None | device_class | ||
| ) |
Translate provided state using cached translations for currently selected language.
Definition at line 463 of file translation.py.
| bool homeassistant.helpers.translation.async_translations_loaded | ( | HomeAssistant | hass, |
| set[str] | components | ||
| ) |
Return if the given components are loaded for the language.
Definition at line 426 of file translation.py.
| dict[str, dict[str, Any] | str] homeassistant.helpers.translation.build_resources | ( | dict[str, dict[str, dict[str, Any] | str]] | translation_strings, |
| set[str] | components, | ||
| str | category | ||
| ) |
Build the resources response for the given components.
Definition at line 74 of file translation.py.
| dict[str, str] homeassistant.helpers.translation.recursive_flatten | ( | str | prefix, |
| dict[str, dict[str, Any] | str] | data | ||
| ) |
Return a flattened representation of dict data.
Definition at line 36 of file translation.py.
|
private |
Definition at line 30 of file translation.py.
| string homeassistant.helpers.translation.LOCALE_EN = "en" |
Definition at line 33 of file translation.py.
| string homeassistant.helpers.translation.TRANSLATION_FLATTEN_CACHE = "translation_flatten_cache" |
Definition at line 32 of file translation.py.