Oliver2
(Oliver)
July 21, 2024, 9:30am
1
I get the following error message:
Failed to execute script: i: Pattern using (localized) text not implemented, use @js-joda/locale plugin!
As documented, I installed a Locale by npm install @js-joda/locale_de-de
in the $OPENHAB_CONF/automation/js folder.
Here is the code:
var Locale = require('@js-joda/locale_de-de').Locale.GERMAN;
console.log(time.LocalDateTime.now().format(time.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale)));
Permissions are set correctly.
Where is my fault?
rlkoshak
(Rich Koshak)
July 21, 2024, 4:37pm
2
The npm install completed without error? Do you see the folder $OH_CONF/automation/js/node_modules/@js-joda/locale_de-de
and does it have contents?
Have you restarted OH since installing the node module? That shouldn’t be necessary but .
What’s the setting Cache setting for the JS Scripting add-on?
Oliver2
(Oliver)
July 23, 2024, 10:44am
3
Yes, I have restarted OH and I can see the locale folder including its content:
/etc/openhab/automation/js/node_modules/@js-joda /locale_de-de/dist `
-rw-r--r-- 1 openhab openhab 328264 Jul 20 23:49 index.esm.js
-rw-r--r-- 1 openhab openhab 262973 Jul 20 23:49 index.esm.js.map
-rw-r--r-- 1 openhab openhab 359043 Jul 20 23:49 index.js
-rw-r--r-- 1 openhab openhab 263063 Jul 20 23:49 index.js.map
-rw-r--r-- 1 openhab openhab 180615 Jul 20 23:49 index.min.js
-rw-r--r-- 1 openhab openhab 2328 Jul 20 23:49 js-joda-locale.d.ts
JS settings are set to
Integrated Variables
Cache Library Injection
It does not make any difference if I change the settings.
Forgot to mention that I am using Java 21.
EDIT: I had to install @js-joda /timezone, too. But the error is still there.
rlkoshak
(Rich Koshak)
July 23, 2024, 1:14pm
4
I managed to do some experiments yesterday and I’m seeing the same error. I know this worked at some point so I think there is a bug or regression or the like that has cropped up. To start file an issue on openhab-js and see where that goes.
I’ve also tried it with e
instead of E
as the docs indicate that’s the localized string but get the same error. I get no error if I remove the “EEEE” part and leave the rest which shows it is not some other type of general formatting problem.
Oliver2
(Oliver)
March 23, 2025, 5:22pm
5
Quite a while, but I found the prolem. It needs to be
console.log(java.time.LocalDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(java.util.Locale.GERMAN)));
instead of
var Locale = require('@js-joda/locale_de-de').Locale.GERMAN;
console.log(time.LocalDateTime.now().format(time.DateTimeFormatter.ofPattern("EEEE, yyyy-MM-dd'T'HH:mm:ss").withLocale(Locale)));
just to let you know as you also experienced the same problem.
1 Like
rlkoshak
(Rich Koshak)
March 25, 2025, 3:09pm
6
Oliver2:
. It needs to be
keep in mind that’s using Java’s date time classes, not joda-js. They are not the same and they are not compatible.