nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.36k stars 3.89k forks source link

I use chinese OS but the window.navigator.language output "en-US" #779

Closed gzlock closed 9 years ago

gzlock commented 11 years ago

Now what can i do to get the user os language I searched for a long time, did not find a way

Content on this page does not help me https://github.com/rogerwang/node-webkit/issues/24

rogerwang commented 11 years ago

hello, what's your OS version?

ndujosh commented 11 years ago

HI. Same issue here with windows 7 64 bit french

kingFighter commented 11 years ago

On Linux, it works fine.Same issue on windows 7 64 bit

ntrf commented 11 years ago

I can confirm that "window.navigator.language" through both DevTools and as javascript: proto in addressbar bar returns "en-US". I'm using russian version of Windows XP SP3. The same line of code otuputs "ru" in regular Chrome (through Dev tools) and "ru-RU" in Firefox (through firebug).

UPDATE: It looks like "window.navigator.language" should return configured browser language which you select during browser installation and can always change in settings menu. It does not refer to the system language. The best possible solution for browser would be to use a server script to return Accepts-Language http header (http://stackoverflow.com/a/3335420). There is nothing on the node.js side as well. So there simply no API for getting user locale currently. I found one addon for node.js (node-locale), but it's native and you will have to compile it.

Probably the simpliest solution is to give user a list of supported languages to choose from on first run.

katanacrimson commented 11 years ago

iirc node-locale is for setting the locale, even; may not be that useful for getting the system locale. You may be able to get the locale though for the current system by way of ENV variables on linux, possibly on mac. Windows will be more difficult though.

rhiokim commented 11 years ago

Same here

I'm using Korean version of Mac 10.8.5, Window 7

When I set Korean(한국어) or English in my system locale

한국어(Korean)

English

Likewise only console.log('process.env.LANG') output en-US.UTF-8

https://code.google.com/p/chromium/issues/detail?id=1862

navigator.language is always set to the UI language of Windows regardless of the UI language of Chrome

And more information

rhiokim commented 11 years ago

@rogerwang Is it done via 723a199 ?

robaweb commented 9 years ago

Have the same issue! Windows 8.1 nw 0.11.6, after building with node-webkit-builder, packing into msi file and installing navigator.language and process.env.LANG are empty But in develop mode and builded with node-webkit-builder without packing in msi navigator.language return correct language.

watdafox commented 9 years ago

Easy fix: take the folder "locales" generated by NW 9 or present in the official zip packages of NW11 & 12. Copy it next to your node-webkit executable. Tadaa.

The issue apparently comes from NW generating an empty locales folder at start instead of filling it with lang.pak files

rogerwang commented 9 years ago

'locales' folder should be shipped with your application.

pouu69 commented 7 years ago

where is locales files?