Allow fetching translations by categories#34329
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with a integration ( |
|
Hey there @home-assistant/frontend, mind taking a look at this pull request as its been labeled with a integration ( |
|
Fixed |
|
@Mariusthvdb this should fix your Hue hiccuping when you open the frontend. |
great! and thanks ;-) happy to report that since upgrading from 107.x to 108.4 the HA instance has never been so fast, responsive and, important, without 'unavailable' (#knockonwood) Hue entities. I've re-instated all core Hue sensors, and they seem very reliable, where before, they would go just as of the 'unavailable' as the lights. Please keep on knocking these details, HA keeps getting better and better. |
| translation_cache: Dict[str, Dict[str, Any]], components: Iterable[str] | ||
| translation_cache: Dict[str, Dict[str, Any]], | ||
| components: Set[str], | ||
| category: Optional[str], |
There was a problem hiding this comment.
What are the other categories than the languages?
| resources[domain].update(translation_cache[component]) | ||
|
|
||
| if category is None: | ||
| domain_resources.update(translation_cache[component]) |
There was a problem hiding this comment.
Does the translation cache contain keys that are either languages or domains?
There was a problem hiding this comment.
categories are the top level entries in strings.json. config, options, etc. A list is here
So the dict is
{ "light": { "device_automation": {…} }
| cache: Dict[str, Dict[str, Any]] = hass.data.setdefault( | ||
| TRANSLATION_STRING_CACHE, {} | ||
| ) | ||
| translation_cache: Dict[str, Any] = cache.setdefault(language, {}) |
There was a problem hiding this comment.
Here we seem to set a language as top level key in the translation cache. How does that match with your description in the comment?
There was a problem hiding this comment.
Sorry, I got confused with all the nested dicts. The translation cache here and what we return is one level below the language key.
There was a problem hiding this comment.
We return translation_cache, which has the described structure.
You're right that cache is { language: translation_cache }.
Breaking change
Proposed change
This allows fetching translations by categories instead of fetching everything at once. This also allows specifying if you want to load a single integration, all set up integrations or all set up integrations + all integrations that have config flows.
Marked WIP until I finish frontend PR.Frontend PR home-assistant/frontend#5560
Part of #34264
Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: