Open mariwing opened 4 years ago
More information; hardcoding 'no' as language in the .js file the card works (humanize-duration-ts supports Norwegian) and displays norwegian for sunset and the length of day.
I would therefore suspect that this line is not picking up the language code correctly for some reason: https://github.com/mishaaq/sun-card/blob/94eee4b6200f5ddd2d5ef6dc9661ed614b81ca8e/src/card.ts#L83
Same issue here: shows up in Lovelace only when language set to English, not to Norwegian.
Describe the bug When language set to "Norwegian Bokmål" on the user profile, the card crashes due to unkown language code "no". If I change it to English the card works as expected.
To Reproduce Click on your name in left menu and change to language "Norwegian Bokmål". Go back to the view where you have added the card and you will see that it doesn't render. In developer tools, you will find this:
Uncaught (in promise) Error: No language undefined. doHumanization sun-card.js:452 humanize sun-card.js:452 renderDaylight sun-card.js:700 render sun-card.js:620 update sun-card.js:186 update sun-card.js:616 performUpdate sun-card.js:148 _enqueueUpdate sun-card.js:148 _requestUpdate sun-card.js:148 initialize sun-card.js:148 initialize sun-card.js:186 J sun-card.js:148 ne sun-card.js:186 a sun-card.js:616 createElement ute:1 s chunk.c136a66895309b59c3fe.js:13138 d chunk.c136a66895309b59c3fe.js:13138 d chunk.c136a66895309b59c3fe.js:13138 l chunk.c136a66895309b59c3fe.js:13138 Vt chunk.c136a66895309b59c3fe.js:12159 value chunk.c136a66895309b59c3fe.js:23707 value chunk.c136a66895309b59c3fe.js:24142 value chunk.c136a66895309b59c3fe.js:23707 n app.664a8247.js:1 d chunk.c136a66895309b59c3fe.js:13138 sun-card.js:452:212500 _enqueueUpdate sun-card.js:148 InterpretGeneratorResume self-hosted:1478 AsyncFunctionNext self-hosted:684 (Async: async) _requestUpdate sun-card.js:148 initialize sun-card.js:148 initialize sun-card.js:186 J sun-card.js:148 ne sun-card.js:186 a sun-card.js:616 createElement ute:1 s chunk.c136a66895309b59c3fe.js:13138 d chunk.c136a66895309b59c3fe.js:13138 d chunk.c136a66895309b59c3fe.js:13138 l chunk.c136a66895309b59c3fe.js:13138 Vt chunk.c136a66895309b59c3fe.js:12159 value chunk.c136a66895309b59c3fe.js:23707 value chunk.c136a66895309b59c3fe.js:24142 value chunk.c136a66895309b59c3fe.js:23707 n app.664a8247.js:1 d chunk.c136a66895309b59c3fe.js:13138
Expected behavior Fallback to a defined language if the card stumbles upon a unknown language. I would guess english is a good default language.
Desktop (please complete the following information):
Additional context If given pointers to where I should add translations for "no" I can submit a PR