Locale in node-red

649 views
Skip to first unread message

Aivaras Jonikas

unread,
Aug 8, 2017, 11:53:23 AM8/8/17
to Node-RED
Hello,

I'm wondering about locale settings in node-red.
I am having issues when parsing the date - I am taking date in UK format e.g. 9/8/2017 and parsing it to UTC format.
The result I am getting is 2017-09-08 instead of 2017-08-09.

Windows settings are all set to English(United Kingdom).

I was browsing through node-red files and I found that there are some files in locale/en-US folder.
Also, I was trying to change defaultLang value in i18n.js, no effect.
Finally, I was searching for some downloads related to setting the right locale, also unsuccessfully.

So how can I change these settings?

Thanks, 
Aivaras 

Nick O'Leary

unread,
Aug 8, 2017, 11:56:14 AM8/8/17
to Node-RED Mailing List
Currently the locale settings only apply to the language the editor/runtime is presented in - it has no affect on number formats, dates etc.

There is a branch that started looking at full bi-directional language support (and by extension, other locale-related preferences) but that work stalled a while ago. It may be picking up again - but its primarily an effort outside of the core node-red project so I can't say when that would be merged into node-red itself.

Nick

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/a90886ed-fb45-44f8-9530-96f8790343de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Julian Knight

unread,
Aug 8, 2017, 1:50:46 PM8/8/17
to Node-RED
node-red-contrib-moment will format and convert date/time strings with locale and timezone as you want them.

Aivaras Jonikas

unread,
Aug 10, 2017, 10:03:10 AM8/10/17
to Node-RED
Hey,

Thanks Julian, it looks like it might be my solution. When reading documentation I found that there is a dependency for 'os-locale' in it.
The usage described as:
const osLocale = require('os-locale');

osLocale().then(locale => {
	console.log(locale);
});
I saw people reporting that this works for them in node.js code but in node-red I am getting result of en_US,
even if my location is set to UK in OS settings. Does it mean that it is taking locale from node-red or there might be any other issues?

Thanks,
Aivaras

Aivaras Jonikas

unread,
Aug 10, 2017, 10:07:08 AM8/10/17
to Node-RED
P.S.: To use it, I am adding the line in \settings.js:

functionGlobalContext: {
   locale: require('os-locale')
}

And then in node-red:

var oslocale = global.get("locale");
oslocale().then(locale => {
console.log(locale);
});

Aivaras Jonikas

unread,
Aug 10, 2017, 10:44:29 AM8/10/17
to Node-RED
Sorry for spamming but the issue was solved. 
In my location settings from Windows Search, setting location to UK didn't set my system locale, so I just had to set it 
in: Control Panel>Region>Change Location>Administrative>Change system locale --- Windows 8.

And changing this setting also solved the issue in parsing the date which was the original question in this thread.

Thanks all for the help!
Aivaras
Reply all
Reply to author
Forward
0 new messages