Skip to content

Commit 86ff844

Browse files
committed
src: add intl and icu configs to process.binding('config')
PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 5b7a011 commit 86ff844

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/node_config.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "node.h"
2+
#include "node_i18n.h"
23
#include "env.h"
34
#include "env-inl.h"
45
#include "util.h"
@@ -28,7 +29,18 @@ using v8::ReadOnly;
2829
void InitConfig(Local<Object> target,
2930
Local<Value> unused,
3031
Local<Context> context) {
31-
// Environment* env = Environment::GetCurrent(context);
32+
Environment* env = Environment::GetCurrent(context);
33+
34+
#ifdef NODE_HAVE_I18N_SUPPORT
35+
READONLY_BOOLEAN_PROPERTY("hasIntl");
36+
37+
#ifdef NODE_HAVE_SMALL_ICU
38+
READONLY_BOOLEAN_PROPERTY("hasSmallICU");
39+
#endif // NODE_HAVE_SMALL_ICU
40+
41+
if (flag_icu_data_dir)
42+
READONLY_BOOLEAN_PROPERTY("usingICUDataDir");
43+
#endif // NODE_HAVE_I18N_SUPPORT
3244
}
3345

3446
} // namespace node

src/node_i18n.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ extern "C" const char U_DATA_API SMALL_ICUDATA_ENTRY_POINT[];
4242
#endif
4343

4444
namespace node {
45+
46+
bool flag_icu_data_dir = false;
47+
4548
namespace i18n {
4649

4750
bool InitializeICUDirectory(const char* icu_data_path) {
4851
if (icu_data_path != nullptr) {
52+
flag_icu_data_dir = true;
4953
u_setDataDirectory(icu_data_path);
5054
return true; // no error
5155
} else {

src/node_i18n.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#if defined(NODE_HAVE_I18N_SUPPORT)
77

88
namespace node {
9+
10+
extern bool flag_icu_data_dir;
11+
912
namespace i18n {
1013

1114
bool InitializeICUDirectory(const char* icu_data_path);

0 commit comments

Comments
 (0)