afvalinfo icon indicating copy to clipboard operation
afvalinfo copied to clipboard

Translations not working as expected

Open jasperslits opened this issue 1 year ago • 2 comments

I am using Home Assistant in English but like to see the Afvalinfo types in Dutch.

The entry is correctly configured:

 { 
        "entry_id": "787cf7f2fa9553328fb01d9aa93da732",
        "version": 1,
        "minor_version": 1,
        "domain": "afvalinfo",
        "title": "Afvalinfo for home",
        "data": {
          "id": "home",
          "postcode": "XXXXX",
          "streetnumber": "XXX",
          "dateformat": "%d-%m-%Y",
          **"locale": "nl",**
          "notrashtext": "geen",
          "getwholeyear": false,
          "sensors": [
            "gft",
            "trash_type_today",
            "trash_type_tomorrow",
            "papier",
            "restafval"

The sensor.afvalinfo_home_trash_type_tomorrow returns "Residual waste" instead of the expected - based on locale - "Restafval".

It seems to be because of https://github.com/heyajohnny/afvalinfo/commit/36962656e190b744c615a626f67fe9177cf19e18 but I am wondering if this is intended as today the locale is only used in sensors.py and not in sensortomorrow.py . Am I missing somewhere?

jasperslits avatar Feb 15 '24 10:02 jasperslits

It's probably because your Home Assistant is in English. The locale is only used for the dates. If you set it to 'nl' and change the dateformat to show text, you could get something like 'Vrijdag 3 december 1995'.

I think you could fix the issue by renaming the sensors: image Please let me know if this fixes your issue.

heyajohnny avatar Feb 19 '24 16:02 heyajohnny

Thanks. I guess a lot of people have HA in English and expect Dutch names for afvalinfo sensors, but seeing I am the first one to raise it…

Renaming sensors will work but I’ll see if I can get this to work (conditionally using nl.json for sensor values) via some Python hacking. Seems less work than getting the config flow to work.

jasperslits avatar Feb 19 '24 17:02 jasperslits

Renaming the sensor values is simpler than a code solution.

jasperslits avatar May 29 '24 07:05 jasperslits