System-technically it seems very simple to me. Months are displayed by default with a number. This number can be converted to the month in the local language.
Strange that such a basic thing is not available in Home Assistant.
The frontend is where the user selects their desired presentation language but templates are processed by the backend. The frontend has no knowledge of the timestamp_custom filter or any other Jinja2 filter.
The backend of the software has no concept of ‘language’. Templates are built into the backend. The frontend also has multiple users with multiple languages. So how would a single template sensor render into multiple different languages in the backend if the template sensor is a single value? It can’t. So, the only option is to have this render in the frontend, where the translations occur per user. Meaning, you can’t do it in the template sensor.
@petro But even the frontend does not know about the language to use, it seems. Create a markdown card in the frontend and use this, {{ now().strftime(“%A %H:%M”) }} as the text. Weekday is in english, regardless of the language used in the frontend.
Yes, and this is by design. I am not saying this is good or bad design, but it is in the frontend and according to your post, the frontend knows or should know about the current users language.
But it is like it is and nothing to do about it at the moment. And I can only hope that the markdown card gets enough priority to be fixed sometime in the future.
And regarding the system language. There is a setting for this in HA and the smart thing to do, is to use this setting for languages in the backend. What else should this setting be used for?
And the new Holiday integration introduced in 2024.1 is using this language setting when creating the holiday calendar. Thumbs up for that. So it is in fact possible to find a solution for this and I don’t think it is difficult either, as the holiday integration has shown.
It does. But that’s only available in JS templates if exposed to the js template engine. Iirc custom button card has this, which is why I mentioned it before.
{% from 'easy_time.jinja' import month %}
# there might be a quicker way to get the moth number,
# depending on the format of the sensor state:
{% set mn = (as_timestamp(states('sensor.start_appliance_awattar'))
|as_datetime).month %}
{{ (as_timestamp(states('sensor.start_appliance_awattar'))
|timestamp_custom('%d. X %Y, %H:%M Uhr'))
.replace('X', month(mn)) }}