Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.translation._TranslationCache Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass)
 
dict[str, str] async_fetch (self, str language, str category, set[str] components)
 
bool async_is_loaded (self, str language, set[str] components)
 
None async_load (self, str language, set[str] components)
 
dict[str, str] get_cached (self, str language, str category, set[str] components)
 

Public Attributes

 cache_data
 
 hass
 
 lock
 

Private Member Functions

None _async_load (self, str language, set[str] components)
 
None _build_category_cache (self, str language, set[str] components, dict[str, dict[str, Any]] translation_strings)
 
dict[str, str] _validate_placeholders (self, str language, dict[str, str] updated_resources, dict[str, str]|None cached_resources=None)
 

Static Private Attributes

tuple __slots__ = ("hass", "cache_data", "lock")
 

Detailed Description

Cache for flattened translations.

Definition at line 147 of file translation.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.translation._TranslationCache.__init__ (   self,
HomeAssistant  hass 
)
Initialize the cache.

Definition at line 152 of file translation.py.

Member Function Documentation

◆ _async_load()

None homeassistant.helpers.translation._TranslationCache._async_load (   self,
str  language,
set[str]  components 
)
private
Populate the cache for a given set of components.

Definition at line 211 of file translation.py.

◆ _build_category_cache()

None homeassistant.helpers.translation._TranslationCache._build_category_cache (   self,
str  language,
set[str]  components,
dict[str, dict[str, Any]]  translation_strings 
)
private
Extract resources into the cache.

Definition at line 303 of file translation.py.

◆ _validate_placeholders()

dict[str, str] homeassistant.helpers.translation._TranslationCache._validate_placeholders (   self,
str  language,
dict[str, str]  updated_resources,
dict[str, str] | None   cached_resources = None 
)
private
Validate if updated resources have same placeholders as cached resources.

Definition at line 258 of file translation.py.

◆ async_fetch()

dict[str, str] homeassistant.helpers.translation._TranslationCache.async_fetch (   self,
str  language,
str  category,
set[str]  components 
)
Load resources into the cache and return them.

Definition at line 181 of file translation.py.

◆ async_is_loaded()

bool homeassistant.helpers.translation._TranslationCache.async_is_loaded (   self,
str  language,
set[str]  components 
)
Return if the given components are loaded for the language.

Definition at line 159 of file translation.py.

◆ async_load()

None homeassistant.helpers.translation._TranslationCache.async_load (   self,
str  language,
set[str]  components 
)
Load resources into the cache.

Definition at line 163 of file translation.py.

◆ get_cached()

dict[str, str] homeassistant.helpers.translation._TranslationCache.get_cached (   self,
str  language,
str  category,
set[str]  components 
)
Read resources from the cache.

Definition at line 192 of file translation.py.

Member Data Documentation

◆ __slots__

tuple homeassistant.helpers.translation._TranslationCache.__slots__ = ("hass", "cache_data", "lock")
staticprivate

Definition at line 150 of file translation.py.

◆ cache_data

homeassistant.helpers.translation._TranslationCache.cache_data

Definition at line 155 of file translation.py.

◆ hass

homeassistant.helpers.translation._TranslationCache.hass

Definition at line 154 of file translation.py.

◆ lock

homeassistant.helpers.translation._TranslationCache.lock

Definition at line 156 of file translation.py.


The documentation for this class was generated from the following file: