Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs, get locale of OS

Tags:

node.js

in python with getdefaultlocale I can get the locale

>>> import locale
>>> locale.getdefaultlocale()
('es_ES', 'UTF-8')

in nodejs exists some similar?

like image 531
JuanPablo Avatar asked Jan 21 '26 19:01

JuanPablo


1 Answers

Unfortunately, it's not as straightforward as it seems. The docs tells the whole story. There's also os-locale that it might be helpful.

But if you happen to be running a simulated browser environment, you can try this: console.log('navigator.language:', navigator.language);

like image 142
Bill_BsB Avatar answered Jan 24 '26 07:01

Bill_BsB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!