Include translation output in templating sensors

Hi,

I do have quite some sensors that are templates, and that put out text, eg:

  somecustomsensor:
    value_template: >
      {% if _something__ %}
        Locked
      {% else %}
        Unlocked
      {% endif %}

So far, so good.
Is there a possibility to format the output in such a way that (depending on the “Language” setting of HA) a different text is presented?
Something like this:

  somecustomsensor:
    value_template: >
      {% if _something__ %}
        [en]Locked
        [de]Verriegelt
      {% else %}
        [en]Unlocked
        [de]Entriegelt
      {% endif %}

So I (with “English” as the language setting) will get Locked, whereas another user (with “German” as the language setting) will see Verriegelt.

Couldn’t find anything in this direction.

Thanks,

Thomas

I thought states were already translated in dashboards depending on your language setting?

States from “proper” sensors may be translated, but not when I write the english words into the template as a string. That string is written exactly as entered, no translation is happening on its own.

I think where some translation happens, its a binary state that HA is converting in text according to the device class? So a “true” in the device class window is then translated into “open” (or another word depending on language setting). At least that’s what I’m guessing.