-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: add navigator.language and navigator.languages #50303
Conversation
Let’s please ping @nodejs/web-standards for all issues and PRs related to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem entirely useful given it's based on the capabilities of ICU which for most is bundled.
Consider this a non-blocking -1 that you may dismiss given there's demand for this behaviour.
f82d7a3
to
5bdd487
Compare
@panva can you explain? What do you mean by “given it’s based on the capabilities of ICU which for most is bundled”? The reason to add these properties, like most of the |
332aa0a
to
74ac025
Compare
I thought about this PR and simplified it. Can you set the default locale of icu in node? If yes, than this PR is still wrong, as it should use that value instead. |
Yes, you can: LC_ALL=en_US node --print 'new Date().toLocaleString()'
10/28/2023, 8:13:49 PM
LC_ALL=en_UK node --print 'new Date().toLocaleString()'
10/28/2023, 20:13:55 I don’t know if
|
It was non-blocking in the first place. If the new approach just returns Intl.DateTimeFormat().resolvedOptions().locale
it's fine.
ec11b6d
to
f0ab0c0
Compare
Nice. LOL, you dont know how much i searched around to find this retrieval opportunity. Falling back to 'en-US' if Intl does not exist. I guess. how can I configure make to build with full intl? I oriented the functionality based on the behaviour of Chrome and Firefox. So if you use defineProperty to overwrite navigator.language, then languages wont be changed, like in the browser. Also the Array of navigator.languages is frozen, like it is in chrome and firefox. Can someone please add the 'author-ready' label and remove the 'c++' and 'i18n-api' labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a test that uses spawnPromisified
to start a Node process with an LC_ALL
of something non-default, and see that it carries through to this new property.
We should also mention in the docs that this environment variable is one way to set Node's default language.
See https://github.com/nodejs/node/blob/65087c04866dad805554102592754f1262bfb3b2/doc/api/intl.md |
fed4162
to
701237a
Compare
@panva PTAL And if somebody approves, please add then the author-ready label :) |
701237a
to
14af167
Compare
Landed in 77b0595 |
PR-URL: nodejs#50303 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: #50303 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This is semver-minor. Collaborators, please think about adding the label in future pull requests. It will make the work of releasers easier. |
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
PR-URL: #50303 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) nodejs#50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) nodejs#50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) nodejs#48740 fs: * add stacktrace to fs/promises (翠 / green) nodejs#49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) nodejs#50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) nodejs#50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) nodejs#50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) nodejs#50097 * use Array for Readable buffer (Robert Nagy) nodejs#50341 * optimize creation (Robert Nagy) nodejs#50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) nodejs#50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) nodejs#48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) nodejs#50443 PR-URL: nodejs#50681
This adds navigator.language and navigator.languages based on the capabilities of ICU.
@anonrig