Skip to content

fix: move translation file I/O off the event loop#95

Open
r0bb10 wants to merge 1 commit into
andbad:mainfrom
r0bb10:fix/blocking-io-translations
Open

fix: move translation file I/O off the event loop#95
r0bb10 wants to merge 1 commit into
andbad:mainfrom
r0bb10:fix/blocking-io-translations

Conversation

@r0bb10

@r0bb10 r0bb10 commented Jul 6, 2026

Copy link
Copy Markdown

Preload translation files into cache via hass.async_add_executor_job before building the dashboard, so _t() calls during dashboard config construction are pure dict lookups with zero blocking I/O.

  • Add _async_preload_translations() that resolves language and loads both the target and English translations via the async executor
  • Updated _build_dashboard_config to accept pre-resolved lang param instead of doing its own I/O

Preload translation files into cache via hass.async_add_executor_job
before building the dashboard, so _t() calls during dashboard config
construction are pure dict lookups with zero blocking I/O.

- Add _async_preload_translations() that resolves language and loads
  both the target and English translations via the async executor
- Updated _build_dashboard_config to accept pre-resolved lang param
  instead of doing its own I/O
@andbad

andbad commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Hi, thanks for the contribution — the approach is clean and the async preload is the right direction.

One thing to clarify before merging: the current codebase calls _STRINGS_CACHE.clear() at the start of _build_dashboard_config to ensure language changes are picked up on every rebuild. Your PR removes that line without replacing it.

Could you check whether _load_strings skips loading if the key is already present in _STRINGS_CACHE? If it does, a language change made by the user would not take effect until HA restarts.

If that's the case, adding _STRINGS_CACHE.clear() at the top of _async_preload_translations before the load loop would fix it.

By(t)e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants