Is there a way to format and translate an item.
I have an DateTime where i it shows the day and month in english and i would like to translate it to danish
Here is my command
say(" Klokken er " + Ntp.state.format("%1$tR") + " idag er det " + Ntp.state.format("%1$tA") + " den " + Ntp.state.format("%1$td") + ". " + Ntp.state.format("%1$tB"),null,AudioSink)
This is my output
Godmorgen allesammen Klokken er 22:01 idag er det Thursday den 29. November
And i would like Thursday and November to be translated
I did try with some mapping, but i cant see where to put it in, i did try this with no luck.
[MAP(dk.map)%1$tA]
say(" Klokken er " + Ntp.state.format("%1$tR") + " idag er det " + Ntp.state.format([MAP(dk.map)"%1$tA"]) + " den " + Ntp.state.format("%1$td") + ". " + Ntp.state.format("%1$tB"),null,AudioSink)
This is the output
Godmorgen allesammen Klokken er 22:24 idag er det [MAP(dk.map)Thursday] den 29. November
Hopefully this will be enough to get you pointed in the right direction.
With this in dk.map (sorry, I only Googled today’s day of week in Danish)
1=Monday in Danish
2=Tuesday in Danish
3=Wednesday in Danish
4=Torsdag
5=Friday in Danish
6=Saturday in Danish
6=Saturday in Danish
7=Sunday in Danish
And with this code in a rule:
var int dayOfWeek = now.getDayOfWeek
logInfo("test", "Day of Week: {}", dayOfWeek)
var String dayOfWeekInDanish = transform("MAP", "dk.map", dayOfWeek.toString)
logInfo("test", "Day of Week in Danish: {}", dayOfWeekInDanish)
var int monthOfYear = now.getMonthOfYear()
logInfo("test", "Month of Year: {}", monthOfYear)
Will produce this output:
2018-11-29 20:41:07.931 [INFO ] [.eclipse.smarthome.model.script.test] - Day of Week: 4
2018-11-29 20:41:07.932 [INFO ] [.eclipse.smarthome.model.script.test] - Day of Week in Danish: Torsdag
2018-11-29 20:41:07.933 [INFO ] [.eclipse.smarthome.model.script.test] - Month of Year: 11