-
-
Notifications
You must be signed in to change notification settings - Fork 61
Clock view and translation of short date string #379
Description
One remark regarding Clock view and translations: It will show date corresponding to user selected language in short form but will not be linguistically accurate, probably because you forced English layout.
Example, your Clock view will produce:
en: Sat, Mar 7
sr: суб, мар 7
sr-Latn: sub, mar 7
This is NOT correct for Serbian. And I can assume for other languages as well if they do not use en layout.
But if I change code and let HA make short version on the date it looks like this:
en: Sat, Mar 7
sr: суб 7. мар
sr-Latn: sub 7. mar
This is correct version of short date for Serbian
What I did? Edit Clock view and replaced your
date: "[[[ return variables.var_date_short ]]]"
with:
date: |
[[[
var now = new Date();
return now.toLocaleDateString(hass.language, { weekday: 'short', month: 'short', day: 'numeric' });
]]]
Now HA can show correct short date per selected language, or long by just changing short to long.
Problem is that not every language uses form: Day, Month number, Serbian uses: day number. month and some other languages maybe using some other combo