amaximus / garbage-collection-card

Custom Lovelace card for Garbage Collection custom component
MIT License
127 stars 24 forks source link

Language change #77

Closed Ecoplay600 closed 3 years ago

Ecoplay600 commented 3 years ago

where can i change language?

amaximus commented 3 years ago

The language used by default is the browser's language. You may override this by hass_lang_priority. This will display the card in the language set in HASS (if translation is available).

Ecoplay600 commented 3 years ago

As I see the language is not hungarian like you said, but In my HA language is Hungary, where can I put hass_lang_priority ? to config.yaml ?

amaximus commented 3 years ago

You'll have to use hass_lang_priority in the card configuration if you want to have the language set in Home Assistant to take priority over browser's language.

Ecoplay600 commented 3 years ago

But if I add this to my card config then the language, like the rubbis take out "tomorrow" is not changed to "holnap"

amaximus commented 3 years ago

You might need to clear the browser cache and reload the page.

amaximus commented 3 years ago

Any update on this issue?

Ecoplay600 commented 3 years ago

The problem not solved. I don't even know why, but you're addon is still english, and not Hungary. I do anytink from you're instructions.

amaximus commented 3 years ago

Please let me know the language your browser is set to. In Chrome you can find this at: Settings->Advanvced->Languages. Which one is the first in the list?

Please also provide the card's full configuration.

Ecoplay600 commented 3 years ago

My browser language is Hungary

  - type: entities
    entities:
      - entity: sensor.fekete_kuka
      - entity: sensor.sarga_kuka
    title: Kuka szállítás

I delete the card, now i use this, can i translate it to hungary?

amaximus commented 3 years ago

Please note that you are using default entities card from Lovelace, not the custom garbage collection card.

Once the card is installed and added to the resources, the custom garbage collection card definition could be something like:

 - type: custom:garbage-collection-card
   entity: sensor.fekete_kuka
   icon_size: 35px
   icon_color: green
   hide_date: true

Please note that the custom garbage collection card does not support multiple sensors yet, so if you have two sensors (fekete_kuka, sarga_kuka) you should have two card definitions, one for each sensor.

Ecoplay600 commented 3 years ago

okay, and where can I add the hass_lang_priority ?

amaximus commented 3 years ago

You could extend the the above card definition with the extra hass_lang_priority, like:

- type: custom:garbage-collection-card
  entity: sensor.fekete_kuka
  icon_size: 35px
  icon_color: green
  hide_date: true
  hass_lang_priority: true
Ecoplay600 commented 3 years ago

It's not working, it still said tomorrow Képkivágás

Code: type: 'custom:garbage-collection-card' entity: sensor.sarga_kuka icon_size: 35px icon_color: green hide_date: true hass_lang_priority: true

Config:

amaximus commented 3 years ago

It's because you are using verbose_state: true for the sensor. Of course if you set verbose_state to false you will loose the string provided by verbose_format. In exchange you'll let the card to format the displayed string and you can control it at the card. Now it's controlled at the sensor.

amaximus commented 3 years ago

The sensor doesn't have Hungarian translation as per [1]

[1] https://github.com/bruxy70/Garbage-Collection/tree/development/custom_components/garbage_collection/translations

Ecoplay600 commented 3 years ago

hmm, it's strange as i remember I had before.

Ecoplay600 commented 3 years ago

What if I change maybe the DE translate? how can I use the DE config?

Ecoplay600 commented 3 years ago

I changed config on sensorEN.json but it's not changed in main page

amaximus commented 3 years ago

The custom card will bypass the string part if verbose_state is true.

Try to set Lovelace language to German. The sensor's Readme doesn't details the translation part.

For your last note: you'll have to restart HASS.

amaximus commented 3 years ago

You may also create a sensorHU.json based on sensorEN.json.

Ecoplay600 commented 3 years ago

I always restart HASS when I change somethink in config, but nothink happened :/

Ecoplay600 commented 3 years ago

Képkivágás

amaximus commented 3 years ago

The garbage collection sensor's translation should be (if you modify the English related file (sensor.en.json)):

{
    "state": {
        "garbage_collection__schedule": {
            "today": "Ma",
            "tomorrow": "Holnap"
        }
    }
}
Ecoplay600 commented 3 years ago

I change it to this, and nothink happened, just noting see under the title

amaximus commented 3 years ago

It was the ${HASS_CONF}/custom_components/garbage_collection/translations/sensor.en.json, right? And you restarted HASS afterward?

Ecoplay600 commented 3 years ago

Yes

amaximus commented 3 years ago

Can you copy here the content of sensor.en.json?

Ecoplay600 commented 3 years ago

{ "state": { "garbage_collection__schedule": { "today": "Ma", "tomorrow": "Holnap" } } }

amaximus commented 3 years ago

And HASS is set to English, right?

Ecoplay600 commented 3 years ago

no it's hungary then I need to create sensor.hu.json? to make it work?

amaximus commented 3 years ago

yes

Ecoplay600 commented 3 years ago

still not working

amaximus commented 3 years ago

It's named sensor.hu.json, located in ${HASS_CONF}/custom_components/garbage_collection/translations/sensor.en.json, HASS restarted afterwards? HASS running in Hungarian? That should work. You may try setting the browser to Hungarian as described earlier above.

Ecoplay600 commented 3 years ago

very strange what this, it's okay for me, but very strange Képkivágás

Ecoplay600 commented 3 years ago

that's okay for me

amaximus commented 3 years ago

try to clear the browser's cache and reload the page.

Ecoplay600 commented 3 years ago

Working, thank you :D

amaximus commented 3 years ago

Great.