Skip to content

Commit 54e20c1

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
deps: V8: cherry-pick e74d0f437fcd
Original commit message: [api] add v8::Isolate::GetDefaultLocale() This allows embedders to query the default locale used by Intl APIs. This information is already available to user land via Intl?.Collator().resolvedOptions().locale, the issue with this is that it's a lot slower and requires dynamic access to Intl API, which is subject to patching and prototype pollution so it's not as reliable for embedders than having a V8 API to query the default locale directly. Refs: #54279 Change-Id: I5a1823993c9ae79f8f61f54c6464daf882a09ba3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5772938 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Commit-Queue: Joyee Cheung <joyee@igalia.com> Cr-Commit-Position: refs/heads/main@{#95678} Refs: v8/v8@e74d0f4 PR-URL: #54279 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c44d41b commit 54e20c1

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.13',
39+
'v8_embedder_string': '-node.14',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/include/v8-isolate.h

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdint.h>
1010

1111
#include <memory>
12+
#include <string>
1213
#include <utility>
1314

1415
#include "cppgc/common.h"
@@ -1717,6 +1718,12 @@ class V8_EXPORT Isolate {
17171718
*/
17181719
void LocaleConfigurationChangeNotification();
17191720

1721+
/**
1722+
* Returns the default locale in a string if Intl support is enabled.
1723+
* Otherwise returns an empty string.
1724+
*/
1725+
std::string GetDefaultLocale();
1726+
17201727
Isolate() = delete;
17211728
~Isolate() = delete;
17221729
Isolate(const Isolate&) = delete;

deps/v8/src/api/api.cc

+11
Original file line numberDiff line numberDiff line change
@@ -10768,6 +10768,17 @@ void v8::Isolate::LocaleConfigurationChangeNotification() {
1076810768
#endif // V8_INTL_SUPPORT
1076910769
}
1077010770

10771+
std::string Isolate::GetDefaultLocale() {
10772+
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
10773+
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
10774+
10775+
#ifdef V8_INTL_SUPPORT
10776+
return i_isolate->DefaultLocale();
10777+
#else
10778+
return std::string();
10779+
#endif
10780+
}
10781+
1077110782
#if defined(V8_OS_WIN) && defined(V8_ENABLE_ETW_STACK_WALKING)
1077210783
void Isolate::SetFilterETWSessionByURLCallback(
1077310784
FilterETWSessionByURLCallback callback) {

0 commit comments

Comments
 (0)