How to convert a DateTime item to German

Tags: #<Tag:0x00007f617b29e328> #<Tag:0x00007f617b29e210> #<Tag:0x00007f617b29e0f8>

Hello,

I try to convert a DateTime item to German but I fail.

I tried to combine formatting and transforming as shown here


but this does not create the expected result.

If I define

DateTime DateAndTime		"Datum und Zeit [%1$tA, %1$td.%1$tB.%1$tY -- %1$tR]"	<clock>

the output is
"Datum und Zeit Monday, 10.July.2017 – 19:15"
which is basically what I expect.
But now I want this in German.

When I define therefore my DateTime item like this

DateTime DateAndTime		"Datum und Zeit [MAP(deDays.map):%1$tA, %1$td.MAP(deMonths.map):%1$tB.%1$tY -- %1$tR]"	<clock>

with deDays.map as

Monday=Montag
Tuesday=Dienstag
Wednesday=Mittwoch
Thursday=Donnerstag
Friday=Freitag
Saturday=Samstag
Sunday=Sonntag

and deMonths.map as

January=Januar
February=Februar
March=März
April=April
May=Mai
June=Juni
July=Juli
August=August
September=September
October=Oktober
November=November
December=Dezember

the output is
"Datum und Zeit July.2017 – 19:10"

Therefore the question

  • Is it not allowed to combine multiple time transforming with formatting in one item definition?

Any idea?

Thx
Axel

I’m going to assume that you are running openHAB on Linux.

According to this posting:

this should be possible.

Open the /etc/default/openhab2 file using vi, nano, or any other text editor and add or update the following options to the EXTRA_JAVA_OPTS variable:

EXTRA_JAVA_OPTS="-Duser.country=DE -Duser.language=de"

Next restart openHAB:

sudo systemctl restart openhab2.service

or simply reboot:

sudo reboot

Hi Marcel,

I run a kind of Linux but it is an QNAP NAS (TS-419P) and the mentioned file does not exist.
I searched with “find” the filesystem but I could not identify a file in which I should put the option.

Further I found the BasicUI configuration a possibility to define country and language but that has no effect on the transformation.

Any other hind?

Regards,
Axel

Hi Axel,

I have no experience with a QNAP NAS, but I did some searching and found the following topic.

The interesting part is this:

So apparently there is a openHAB-wrapper.conf file. In this file you should be able to add the -Duser.country=DE and -Duser.language=de settings similar to how @Pezza added the gnu.io.rxtx.SerialPorts setting.

The downside of this method is that this most likely needs to be done after every update of openHAB.

You could of course open an issue in the openhab-qnap-qpkg issue tracker so that hopefully a solution similar to the /etc/default/openhab file on Linux can be created.

Thanks for the hint, but the thread is talking about OH2 and I run OH1.8.2 where the mentioned mapping file does not exist.
So I need to search further for a solution to change the DateTime conversion.

Regards,
Axel

What languages ​​can I translate to, I would like to have Danish, this can be done?

EXTRA_JAVA_OPTS="-Duser.country=DE -Duser.language=de"

Assuming that you have read this topic and understand to what part of openHAB this applies (this does not automagically translate openHAB to Danish), try:

EXTRA_JAVA_OPTS="-Duser.country=DK -Duser.language=da"

1 Like

Hi

I did try this to translate to danish, and it works

EXTRA_JAVA_OPTS="-Duser.country=DK -Duser.language=da"

but now I’m having trouble showing my date correct date from 1. to 9. Shows like 01 - 09.
So today’s date is shown like 02. December.

So when I use the say command in a rule it tells me the date like, today it is the zero 2nd December

Is there a way to remove this 0 from from 1.-9,
It looks like it’s generally everywhere in openhab it’s changed to two digit numbers in the date

This is my output in the log

2018-12-02 23:46:32.011 [INFO ] [rthome.model.script.Godmorgen hilsen] - SayText: Godmorgen allesammen Klokken er 23:46 og idag er det søndag den 02. december Temperaturen udenfor er lige nu 7,1 Grader

Make a custom string format using only a single “d” for the day instead of “dd”.

Hi

I’m using this say command on my sonos speaker, I dont think it is the same codes i’m using.

This is my say command:

SayText2="Klokken er " + Ntp.state.format("%1$tR") + " og idag er det " + Ntp.state.format("%1$tA") + " den " + Ntp.state.format("%1$td") + ". " + Ntp.state.format("%1$tB")    
  	  	

and this is my date

Ntp.state.format("%1$td")

And this is the state on my Ntp DateTime item:

2018-12-03 19:10:11.089 [vent.ItemStateChangedEvent] - Ntp changed from 2018-12-03T19:09:11.054+0100 to 2018-12-03T19:10:11.063+0100

Hi I did solve it, I change the code from

Ntp.state.format("%1$td")

to

Ntp.state.format("%1$te")

Thanks

1 Like