Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Ability to translate attributes and states #102

Open
robinjhector opened this issue Apr 12, 2022 · 2 comments
Open

[FR] Ability to translate attributes and states #102

robinjhector opened this issue Apr 12, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@robinjhector
Copy link

robinjhector commented Apr 12, 2022

Is your feature request related to a problem? Please describe.

Not sure

Describe the solution you'd like

Some easy way of interpolating the translated strings.

Describe alternatives you've considered

N/A

Additional context

Given I have sensor, that has a state:
sensor.ehm6g88s_status -> awaiting_start.

This is translated in the custom component, so how do i get the translated string in my card?
If I were to use a regular Entity card or similar, it would be translated properly. How do I achieve the same-ish behaviour with the config-template-card?

Here's an example:

- type: custom:config-template-card
  entities:
    - sensor.ehm6g88s_status
  card:
    type: button
    show_name: true
    show_icon: true
    state_color: false
    tap_action:
      action: toggle
    entity: switch.ehm6g88s_smart_charging
    icon: mdi:power
    show_state: false
    name: ${states['sensor.ehm6g88s_status'].state}
@ildar170975
Copy link
Collaborator

Inside config-template-card you can use JS to access to HA objects.
I guess (may be wrong) that translations ("above_horizon -> Above horizon", "on -> Connected") are not part of these objects...

@ildar170975 ildar170975 changed the title Ability to translate attributes and states [FR] Ability to translate attributes and states Jan 16, 2024
@ildar170975
Copy link
Collaborator

Currently translations are not a part of states object.
They cannot be read in jinja templates - and in JS templates as well.
This may probably be made as a local "helper function" (like it is made for custom:button-card).

Converted to FR.

@ildar170975 ildar170975 added the enhancement New feature or request label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants