intents
intents copied to clipboard
How to translate `state` values?
While developing for Finnish translations, I tried to find a way to translate the state in Finnish instead of English with getState.
For example, I wanted to translate the one_yesno
case where the English No, {{ state.state_with_unit }}
returns No, off
.
In Finnish it would be: Ei, {{ state.state_with_unit }}
which returns Ei, off
. The word "off" is not Finnish and I wanted to translate it.
I found that in tests/nb/_fixtures.yaml
there are state in and out pairs and the out
word is replaced with in
word when running tests.
entities:
- name: Soveromlampe
id: light.bedroom_lamp
area: bedroom
state:
in: "av"
out: "off"
If I create similar bedroom lamp in Finnish fixtures and put in: "pois päältä"
, I get the translation to return Ei, pois päältä
.
But this seems a wrong way to handle translating states as it's tied to each device and all users would have to translate their states themself while maintaining compatibility with this codebase.
So, what is the correct way to translate states properly?
Is there an example language that's kept up to date with the English version by the core team where I should go for recommended examples? Or is there a more in depth place for documentation like this that I'm missing?
I have the same question. For now I just removed {{ state.state_with_unit }}
from No, {{ state.state_with_unit }}
as it serves no purpose at the moment. There are translations of device states in HA, maybe it will use those translations instead of us trying to translate all different states in here?
The state will be translated automatically in Home Assistant according to the existing strings.json
files, like @ErnestStaug mentioned.
Sorry to bother, where can I find this strings.json in Finnish?
I did find this with google: https://github.com/home-assistant/core/blob/dev/homeassistant/strings.json
The state will be translated automatically in Home Assistant according to the existing
strings.json
files, like @ErnestStaug mentioned.
For Swiss German (de-CH) according to my understanding no HA translation exists. How can translations of states be handled in such a case? This also relates to the question of choosing the language for Assist differently from HA's language (#1013). Not sure if other localization are also affected, but at least for Swiss German I would assume that most users with [de-CH] for Assist would have [de] or [en] for HA, as Swiss German predominantly is a spoken language.
I would suggest to have the possibility to provide translations in "intents" as fallback.
@synesthesiam Could you provide for use very small example how to correctly create test with translations with this case? I also have the same issue, and from my side I just start using conditions to correctly show response from status eg:
Nie, {{ slots.name }} jest {{ 'otwarta' if state.state_with_unit == 'open' else 'zamknięta' }}
. But this configuration is very hard to maintenance and probably they generate lot of other issue (like wrong response for state like 'working')