OH4 Transformation in GUI

hi,
I have Astro binding with several items, one of them LocalSun_Rise_StartTime, type of DateTime.
From this item with the following pattern: %1$tA, %1$td.%1$tm.%1$tY I am able to get it to this format: “Thursday, 08.02.2024”
I would like to have Thursday translated to local language. I have necessary mapping in the weekdays.map file.
It used to work in 2.x where all these things were in the files only, after moving to 3.x and 4.x shortly after, where things are mostly in GUI, I don’t know where the configure it properly and how (Pattern in the Item, sitemap, elsewhere?)

It should already be giving you the localized name for Thursday. Have you set your language in the Regional Settings?

If so, what’s the language set for your operating system running OH?

In answer to your question, the pattern gets defined in the State Description Item metadata, the Pattern field. That is where you add what you would add between the [ ] in the label in a .items file. But I’m not sure if you can use a map transformation for this because you already have to apply the date time formatting.

@rlkoshak the language of OH is correct (Polish)


(browser in in English)
OS running OH is as follows:

pi@dom-pi:~ $ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
pi@dom-pi:~ $ locale -a
C
C.UTF-8
en_US.utf8
pl_PL.utf8
POSIX
pi@dom-pi:~ $

But I wouldn’t like to change anything, just force the mapping file which worked before. Simply don’t know where to tell the system to use the mapping? in the pattern? but then how to tell it to map just one value? I swear it was working in 2.x, changed after 3.x/4.x

Did you try to change the prefered language in the browser? A subset depends on the browser language.

I don’t see how it ever worked before. Show how you configured it. There’s no chaining of transformations on an Item label so how can you apply both the Map transform and the date time pattern? And even then, how do you map just the day part?

Again, as I said, you put what you used to have between the [ ] in the Item’s label field in the .items file into the State Description metadata’s Pattern field. That part works exactly the same as it has always done.

Same way you did it in OH 2.x. What that is :man_shrugging: . As far as I know this has never been possible using a map transform.

Ultimately, this isn’t the only place that you will run into problems if your locale isn’t right. Your RPi is set to English-US. As long as that’s the case the default any time you do any locale related operation is going to be in English.

I’m not sure that would address this. The String formatting of the Item state takes place on the server side, not the browser side. It use String Format and according to the docs:

'A' Locale-specific full name of the day of the week, e.g. "Sunday", "Monday"

and elsewhere it says

The locale always used is the one returned by Locale.getDefault(Locale.Category) with FORMAT category specified.

This means that %1$tA is always going to return the English “Tuesday” until the LC_TIME locale is set to pl_PL.utf8 on the OS.

I have other devices which are in the local language completely, e.g. Android device with OS and browser in Polish but still same ‘Thursday’

Thanks Rich, I will try to play with LC_TIME but I never had it set differently. There must be something different in how OH3/4 uses the OS configuration or own locale configuration.

If there is a difference, it’s most likely a change in how Java 8 worked compared to Java 11 (OH 3) and Java 17 (OH 4). The processing of the String formatting and locale handling and all that is built into Java itself. OH just uses it.

Ha! this is funny! OH is still in English but OS is in local format!
image
image
system rebooted and uses locale as it should


got lost now …

A restart of OH probably would have been sufficient. Java just doesn’t pick up the changes to the OS until it’s restarted.

I’m not sure how to read this. Is it working or not working?

not working and obviously OS rebooted (to your comment that Java doesn’t pick it up).
image
(so reboot 18.20 and OH start 18.22)

I’ve never changed just the one locale property. I assumed that Java picks up all the properties and applies them accordingly. But it might be the case that it only looks at one of them (which one? :person_shrugging: ). You can try changing the complete locale instead of just the one for time and see if that makes a difference.

I’m using zulu17 jdk now, maybe this is where I need to check the settings. Will try to investigate

I found exactly the same approach which was working for me before upgrading to OH3.x / OH4.x - mapping of weekday to local language: Datetimeitem language