[SOLVED] Translate day names in items

I found this tread [SOLVED] How to translate a sensor value (number) to text using map transformation
which translates the return value 1 or 2 to the value Low or High.
I would like to do a similar thing; translate the the day name in my weatheunderground configuration.

When i use the default Englisch terms, everything works fine:

items:

DateTime   ObservationTime0    "Observatietijdstip [(%1$tA)]"    <time>   (Weather)   {channel="weatherunderground:weather:local:forecastToday#forecastTime"}

That gives the current day name (Wednesday) on my site map. So i tried to use the solution in the tread mentioned to my config:

DateTime    ObservationTime0    "Observatietijdstip [MAP(dagen.map):(%1$tA)]"   <time>   (Weather)   {channel="weatherunderground:weather:local:forecastToday#forecastTime"}

Created the dagen.map file in the transform directory with the values:

Monday=Maandag
Tuesday=Dinsdag
etc.

But that does not work… Does anyone have a suggestion how to handle this?

No it will not work, the item is not a string but a DataTime. The value sent to the transform file is the DateTime NOT the day of the week.

Have you changed your locale in openHAB and in your computer?

Hi @vzorglub thank you for your reaction. Yes, that makes sense; So perhaps i have to live with that :wink:
My openhab is using the English language as is my PC. I find that more convenient because most info and examples are in English. But is it’s not improving on the WAF, so whenever it can i try to translate in the sitemap.
Is there not a solution to translate DatTime item types in openhab?

Your will need another item and a rule:

DateTime   ObservationTime0    "Observatietijdstip [(%1$tA)]"    <time>   (Weather)   {channel="weatherunderground:weather:local:forecastToday#forecastTime"}
String ObsString0 " "Observatietijdstip [%s]"

rule:

rule "translate days"
when
    Item ObservationTime0 changed
then
    ObsString0.postUpdate(tranform("MAP","dangen.map", triggeringItem.toString(%1$tA)))
end
1 Like

Hi Vincent (@vzorglub),
Thank you very much; this works OK for me!
(It took me some time, because i messed-up something else in my config.)
But it all works well now. Regards, Bert

Great, please tick the solution, thanks

Don’t understood why but it doesn’t work for me using Openhab 2.5.

I have found one other solution:

rule "translate days0"
when
    Item localDailyForecastTodayTimestamp changed
then
    localDailyForecastTodayDayFR.postUpdate(transform("MAP", "fr.map", triggeringItem.state.format("%1$tA")))
end