mirror of
https://github.com/home-assistant/core.git
synced 2026-07-01 19:57:08 +01:00
b9575ee881
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: balloob <1444314+balloob@users.noreply.github.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
22 lines
681 B
Python
22 lines
681 B
Python
"""Helper functions for use with IRM KMI integration."""
|
|
|
|
from homeassistant.config_entries import ConfigEntry
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from .const import CONF_LANGUAGE_OVERRIDE, LANGS
|
|
|
|
|
|
def preferred_language(hass: HomeAssistant, config_entry: ConfigEntry | None) -> str:
|
|
"""Get the preferred language for the integration.
|
|
|
|
Returns the overridden language if set in configuration.
|
|
"""
|
|
|
|
if (
|
|
config_entry is None
|
|
or config_entry.options.get(CONF_LANGUAGE_OVERRIDE) == "none"
|
|
):
|
|
return hass.config.language if hass.config.language in LANGS else "en"
|
|
|
|
return config_entry.options.get(CONF_LANGUAGE_OVERRIDE, "en")
|