Datetimeitem language

Are there any specific language available to Datetimeitem?
I am able to select en_EN and de_DE, but pt_BR is not working.

I am not able to change language for “Lastupdate” using Datetimeitem.
Is there any default language configuration?

Thanx!

You have to use a transform file. Set the language to en_EN and make a file called weekday.map. Inside the file you can put your translations. I have done this for Dutch. This is my content.

Sunday=Zondag
Monday=Maandag
Tuesday=Dinsdag
Wednesday=Woensdag
Thursday=Donderdag
Friday=Vrijdag
Saturday=Zaterdag

Put this file int the transform directory located in the configurations directory.

Please find my string for the items file. You have to let OpenHAB know that you want to translate.

DateTime Forecast_Day_1   "[MAP(nl.map):%1$tA]"	{weather="locationId=home, forecast=1, type=condition, property=observationTime"}
DateTime Forecast_Day_2   "[MAP(nl.map):%1$tA]" {weather="locationId=home, forecast=2, type=condition, property=observationTime"}

Hope it helps you.

Hello Erwin,

Unfortunately this solution did not work.
I did your instructions and rebooted my RaspPi.
With MAP translation file/method added Datetimeitem just does not appear in interface.

I just did not understand that you created a weekday.map file and your Forecast calls a nl.map file.

But thanx!

@all_mac07 try replacing the ‘=’ with a blank space. See my post for more information Value mapping using transform file

My demo.items:

DateTime        Date    "Data [MAP(weekday.map):%1$tA, %1$td.%1$tm.%1$tY]"      <calendar>      { ntp="America/Brasilia:en_EN" }

My new weekday.map (inside configurations/transform folder):

Sunday Domingo
Monday Segunda
Tuesday Terça
Wednesday Quarta
Thursday Quinta
Friday Sexta
Saturday Sábado

No Date and Time:

Check if the ntp binding is making a connection to the ntp server. You should see this in the log files once logging is enabled.

Lastest information (Warn) were 7 hours ago…

18:36:22.508 WARN  o.o.b.ntp.internal.NtpBinding[:122]- couldn't establish network connection [host 'a.ntp.br'] -> returning current sytem time instead

And 2 minutes ago…

2015-09-10 01:08:51 - Date state updated to 2015-09-10T01:08:51

I was not successful in getting date time with 1.7.0. It always gave me a not able to connect to server error but I was busy fixing mybzwave devices so never looked further. However with 1.7.1 all seems to work well. Below is my item definition
DateTime Date “Date [%1$tA, %1$td %1$tb,%1$tY %1$tT]” { ntp=“America/Chicago:en_US” }

And my ntp configuration is as below

ntp:refresh=900000

the hostname of the timeserver

ntp:hostname=pool.ntp.org

Mahesh,

Back to my main problem… :yum:

I am able to show date and time informations, however weekday appears in ENGLISH.
I need to show this information in another language (for example spanish, portuguese or japanese).

So… main problem is how to do this?
When I add MAP translation service and Translation rule (.map file), date and time information do not appears.

Regards.

Out of interest, what’s your JVM Language?

ie. run this as a Rule and look at the output in openhab.log:

import java.util.Locale

rule "Test Locale"
when Time cron "0/10 * * * * ?"
then
  val Locale LOCALE = Locale::getDefault

  logInfo('locale', LOCALE.toString)
end

It’s possible that some i18n elements aren’t printed correctly because the JVM settings aren’t setup (or are defaulting to US). These are typically picked up from the OS, in an OS dependent manner. For Linux, it involves specific Environment variables (think LANG, LANGUAGE)

14:37:10.008 INFO o.openhab.model.script.locale[:53]- en_US

Your openHAB machine is running on an OS that’s configured for English. Java sees that, and internally defaults it’s Locale to match.

Switch your OS over to the Locale you’re interested in, and all output/display functions in Java should cutover as well… at least they will in a correctly NLS’d (or MLS’d) app.

Internally DateTime is language neutral, so it won’t matter how values get into the DateTime, it’s more about how they format for output purposes.

How you switch the language is OS dependent, but for something common like Linux, it can be done a few ways.

The easiest is to set the LC_ALL variable prior to starting openHAB.

export LC_ALL=en_GB.UTF-8

This likely requires that you have this lang installed (OS-wise). There are command-line overrides on the JVM that’ll probably also work.

To understand how this is done for other OS’s, you can Google and/or use StackOverflow (aka SO) since the model is different across platforms, and in some cases, across versions of Java.

I did this change, but Openhab persist to show weekday in english. Thanks.

pi@openhab ~ $ locale -a
    C
    C.UTF-8
    en_US.utf8
    POSIX
    pt_BR.utf8

pi@openhab ~ $ locale
LANG=pt_BR.UTF-8
LANGUAGE=pt_BR:pt
LC_CTYPE="pt_BR.UTF-8"
LC_NUMERIC="pt_BR.UTF-8"
LC_TIME="pt_BR.UTF-8"
LC_COLLATE="pt_BR.UTF-8"
LC_MONETARY="pt_BR.UTF-8"
LC_MESSAGES="pt_BR.UTF-8"
LC_PAPER="pt_BR.UTF-8"
LC_NAME="pt_BR.UTF-8"
LC_ADDRESS="pt_BR.UTF-8"
LC_TELEPHONE="pt_BR.UTF-8"
LC_MEASUREMENT="pt_BR.UTF-8"
LC_IDENTIFICATION="pt_BR.UTF-8"
LC_ALL=pt_BR.UTF-8

14:37:10.008 INFO o.openhab.model.script.locale[:53]- en_US

You’ll need to show how you’re starting openHAB, and where you’re setting the environment relative to how you’re starting it.

For example, if you make these changes in one shell, but openHAB is starting from another (like init.d scripts) it won’t be picked up. If you make the changes “system-level” in Raspbian, then it’ll probably be picked up on next boot.

I’m guessing you’ve set it in one shell, but you’re starting openHAB in another. I just tweaked my /etc/init.d/openhab script to add the LC_ALL environment to my startup sequence, per the above snippet of shell, and now my sample rule correctly emits:

12:47:53.316 INFO  org.openhab.model.script.locale[:53]- en_GB

where normally, I get en_US.

@all_mac07,
How did you get on, did you get it working?

Not yet.

Hey guys,
I stumbled upon your thread since I had the same issues. After migrating my OH setup to new hardware my date items were in English instead of german from the old setup.
Indeed the language was set different. This is how I rectivied this on my debain server (should also work for raspbian, etc)

env | grep LANG
  LANG=de_DE.UTF-8
  LANGUAGE=en_US:en
export LANGUAGE=de_DE:de
apt-get install dpkg-reconfigure
dpkg-reconfigure locales
Generating locales (this might take a while)...
  de_DE.UTF-8... done
  en_US.UTF-8... done
reboot

While reconfiguring, choose your new language and reboot.
Hope this helps.

1 Like

Hi… it is working now. SOMETIMES!! :stuck_out_tongue:
Let me understand what happens…

Here’s a tutorial on how to achieve your local language for the NTP binding.
No hassle with installing another locale on your Raspberry or other system.
Just keeping the settings of your system. It’s just a few simple steps…

Step 1 - Install the NTP Binding in OpenHab
Step 2 - Go to Things -> Local Time and link the channel “ntp:ntp:local:dateTime” to an item “Date”
(this item you can use in the future for a full date & time text. Example: Sunday, 06.01.2019 20:00)


Step 3 - Create a file called ‘weekday.map’ and put this in the folder ‘\OPENHABIANPI\openHAB-conf\transform’
In this file put the English weekdays and your own language for translation. Example:

Sunday=Zondag
Monday=Maandag
Tuesday=Dinsdag
Wednesday=Woensdag
Thursday=Donderdag
Friday=Vrijdag
Saturday=Zaterdag

Step 4 - Put this line in the home.things file. Change it to your own locale / ntp server if needed.

ntp:ntp:local  [ hostname="nl.pool.ntp.org", refreshInterval=60, refreshNtp=30, locale="Europe/Amsterdam" timeZone="Europe/Amsterdam" ]

Step 5 - Create 2 new items by adding these lines in the home.items file.

DateTime Today  "Datum [MAP(weekday.map):%1$tA]"  { channel="ntp:ntp:local:dateTime" }
	DateTime Time  "[%1$td.%1$tm.%1$tY %1$tH:%1$tM]"  { channel="ntp:ntp:local:dateTime" }

Step 6 - You can now add the items to your sitemap by adding these lines to the home.sitemap file.

Text label="" icon="calendar" item=Today
		Text label="" icon="" item=Time
3 Likes

Hello, :smiley:
it worked, But i get this error

2019-02-27 17:29:47.323 [WARN ] [rest.core.item.EnrichedItemDTOMapper] - Failed transforming the state ‘2019-02-27T17:29:47.288+0100’ on item ‘Today’ with pattern ‘MAP(weekday.map):%1$tA’: Cannot format state ‘2019-02-27T17:29:47.288+0100’ to format ‘%1$tA’

anyone?