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

Danish Translation #234

Closed
mpejstrup opened this issue Jan 5, 2021 · 15 comments
Closed

Danish Translation #234

mpejstrup opened this issue Jan 5, 2021 · 15 comments
Labels
question Further information is requested

Comments

@mpejstrup
Copy link

Hi

I also would like to contribute with a translation:
{
"state": {
"garbage_collection__schedule": {
"today": "i dag",
"tomorrow": "i morgen"
}
}
}

I have tried to fix it myself without luck. I can't get it to work. Rename the file to sensor.dk.json

Have restartet
Have done a Shift+F5
Have done a full cache refresh

@mpejstrup mpejstrup added the question Further information is requested label Jan 5, 2021
@bruxy70
Copy link
Owner

bruxy70 commented Jan 5, 2021

Thanks. I added that to the translations. It will be included in the next release.
For your question - this translates the sensor state if you use verbose state.
If you use the custom garbage collection card, then this one uses a separate translation for some reason, so that will not work for that.

bruxy70 added a commit that referenced this issue Jan 5, 2021
@bruxy70 bruxy70 closed this as completed Jan 5, 2021
@mpejstrup
Copy link
Author

mpejstrup commented Jan 5, 2021

Cool, thanks
I do use verbose state and only the sensor entity....
2021-01-05_16h54_59

              <ha-icon icon="mdi:recycle"></ha-icon> Genbrug afhentes {{ states('sensor.genbrug') }}<br>
              <ha-icon icon="mdi:trash-can-outline"></ha-icon> Affald afhentes {{ states('sensor.affald') }}
              <font color='#6a7377'>

2021-01-05_16h55_28

@bruxy70
Copy link
Owner

bruxy70 commented Jan 5, 2021

I think the Jinja2 templates do not do translations. I think it kind of makes sense. The language is set in the user properties, not system properties. And the Jinja2 template is made for automations, that work on the back end, regardless of who is currently logged in the front end, or even if nobody is logged in. And you do not want your automations to stop working when you change your language settings. Or if you have multiple users with different language settings, what would the automation do?
You can typically tell if the translation is used by the first capital letter (even in English). The actual state should be with first letter in lower case. And the English translation normally capitalize the first letter.
So, if you press letter E, type the entity name (sensor.genbrug) and click on the sensor to get more info, it should display the state in Danish.
Or, even better - if you go to the Developer Tools, States and filter for the sensor, it should display the actual state (in English with lower case). But when you click on the (i) icon to show more info, it should display the translated entity.
So, to display the translated state, use a standard lovelace card.
But I do agree that when you use Jinja2 template on front end, it should go through the translation. That would be nice.

@mpejstrup
Copy link
Author

Hi again

Thanks for the explanation. And I see you already made a new update :)
But I can't get the sensor to translate still?
2021-01-06_10h44_44
2021-01-06_10h44_38

Another question: When I only want to put in specific dates, which "frequency" should i use?
2021-01-06_11h19_32

Lastly: Can I choose to have it display 0 and 1 instead of today and tomorrow?

@bruxy70
Copy link
Owner

bruxy70 commented Jan 6, 2021

Interesting. I have seen that before, and refreshing or clearing browser cache helped.
If you want specific dates, use annual frequency to add one date, and then add the other dates through include dates. Or perhaps a standard google calendar integration might be a better fit for that as it is easier to add such events.
If you do not use Verbose state, the state will be 0 for today, 1 for tomorrow and 2 for other cases. Or you can always create a template sensor based on the garbage sensor integration attributes (e.g. number of days).

@mpejstrup
Copy link
Author

Thanks! That worked..
I'm not that good in templating, how would a template sensor look like, if it should look after 0 and name it "i dag"?
Thanks in advance and thanks for helping so far!

@bruxy70
Copy link
Owner

bruxy70 commented Jan 6, 2021

Simple. Do something like:

sensor:
  - platform: template
    sensors:
      genbrug_verbose:
        friendly_name: "Something friendly"
        value_template: >-
          {% if states('sensor.genbrug') == '0' %}
            i dag
          {% else %}
            {{ states('sensor.genbrug') }}
          {% endif %}

I suggest testing the template in the Developer Tool / Template. Just copy and paste it there (just the value template part) and see what it does.

@mpejstrup
Copy link
Author

Perfect! It works!

Thanks man

@mpejstrup
Copy link
Author

Hi
I just stay in this tread as I have encountered an issue with the config we discussed.
As you can see my next date is 3rd of Feb. and it says 2 days?
We have configured it as annually
Uploading 2021-01-13_08h21_47.png…

@bruxy70
Copy link
Owner

bruxy70 commented Jan 13, 2021

I do not see the picture. If you look at the entities attributes next_date and days. Does it really say the next date is Feb 3 and days is 2? Or are you referring to the entity state? The entity state is not the number of days. It only has 3 states - 0 for today, 1 for tomorrow and 2 for everything else (this allows the use of state images in picture entity cards). For the number of days there is the days attribute.

@mpejstrup
Copy link
Author

Does is work now?
2021-01-13_08h21_47

@mpejstrup
Copy link
Author

Should it then not be 3?

@bruxy70
Copy link
Owner

bruxy70 commented Jan 13, 2021

Sorry typo. It has 3 states: 0, 1 and 2. 0 for today, 1 for tomorrow, 2 for everything else. I see that the days attribute correctly states 21.

@bruxy70
Copy link
Owner

bruxy70 commented Jan 13, 2021

So if you want your template to show this, you need to change it to:

sensor:
  - platform: template
    sensors:
      genbrug_verbose:
        friendly_name: "Something friendly"
        value_template: >-
          {% if states('sensor.genbrug') == '0' %}
            i dag
          {% else %}
            {{ state_attr('sensor.genbrug','days') }}
          {% endif %}

@mpejstrup
Copy link
Author

mpejstrup commented Jan 13, 2021

Works like a charm :)

OEHC added a commit to OEHC/Garbage-Collection that referenced this issue Jul 9, 2022
According to IANA, the correct language subtag for Danish is 'da'.
This explains why @mpejstrup could not get the Danish translation to
work in issue bruxy70#234
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants