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

[Feature Request] Translation or custom "value" #17

Closed
mhoogenbosch opened this issue Sep 28, 2024 · 4 comments · Fixed by #22
Closed

[Feature Request] Translation or custom "value" #17

mhoogenbosch opened this issue Sep 28, 2024 · 4 comments · Fixed by #22
Assignees

Comments

@mhoogenbosch
Copy link
Contributor

I live in the Netherlands, and use the birthdays for showing the kids how long it takes before their birthday is. Now it is only possible to have xx 'days', it would be really nice if it translates to Dutch 'dagen' and 'dag' for 1.

Another approach could be to be able to alter the 'days' to anything you'd like.

@Miicroo
Copy link
Owner

Miicroo commented Sep 28, 2024

@mhoogenbosch Nice, would be good to have! Do you already use dutch as your language in HA, so we can use that, or were you thinking more along the lines of a configuration value where you have to specify it yourself?

@mhoogenbosch
Copy link
Contributor Author

I think it makes sense to comply with the default language of ha indeed. Using Dutch as primary language for ha.

@Miicroo
Copy link
Owner

Miicroo commented Oct 10, 2024

@mhoogenbosch PR is ready! Found a few caveats, the language that is used is the language that is set on your homeassistant instance. I first wanted it to reflect the language that a logged in user can set in their profile, but that doesn't make sense since you can have multiple users with multiple languages, but the sensors are always the same. In the case of for instance push notifications we don't have a user context, and thus it is the instance language that has to decide the values.

I guess most users don't change language that often, so I didn't add any event listener to automatically update language upon changes. If you do change the language (from http://localhost:8123/config/general or configuration.yaml) you have to restart HA for the changes to take effect.

@Miicroo Miicroo linked a pull request Oct 10, 2024 that will close this issue
@Miicroo
Copy link
Owner

Miicroo commented Oct 10, 2024

Another caveat is that, since state is always number of days left, if you list these with auto-entities you will get "0 dagen" if the birthday is today. This can be changed if you use a custom attribute instead (the elif (this.state or -1) == 1 can be merged with the below elif if you want to view it as 1 dag):

birthdays:
  config:
    attributes:
      custom_state: >
        {% if (this.state or -1) == 0 %}
          Vandaag
        {% elif (this.state or -1) == 1 %}
          Morgen
        {% elif (this.state or -1) > 1 %}
          {{ this.state }} {{ this.unit_of_measurement }}
        {% else %}
          Unknown
        {% endif %}
  birthdays:
    - name: more config here for birthdays...

Of course than the UI will have to look at this attribute instead of the state, but just wanted to show that it is possible.

@Miicroo Miicroo self-assigned this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants