heyajohnny / afvalinfo

Provides Home Assistant sensors for multiple Dutch waste collectors. The idea is to add more cities and features in the future.
GNU General Public License v3.0
103 stars 22 forks source link

Translations not working as expected #427

Closed jasperslits closed 5 months ago

jasperslits commented 9 months ago

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?

heyajohnny commented 9 months ago

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.

jasperslits commented 9 months ago

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 commented 5 months ago

Renaming the sensor values is simpler than a code solution.