From cdba9a6c02ba3418feacaefa575d02fab0eb594b Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 19 Apr 2016 16:11:21 -0700 Subject: [PATCH] src: add intl and icu configs to process.binding('config') PR-URL: https://github.com/nodejs/node/pull/6266 Reviewed-By: Ben Noordhuis --- src/node_config.cc | 14 +++++++++++++- src/node_i18n.cc | 4 ++++ src/node_i18n.h | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/node_config.cc b/src/node_config.cc index e50002bc64c..9ffea0bedad 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -1,4 +1,5 @@ #include "node.h" +#include "node_i18n.h" #include "env.h" #include "env-inl.h" #include "util.h" @@ -28,7 +29,18 @@ using v8::ReadOnly; void InitConfig(Local target, Local unused, Local context) { - // Environment* env = Environment::GetCurrent(context); + Environment* env = Environment::GetCurrent(context); + +#ifdef NODE_HAVE_I18N_SUPPORT + READONLY_BOOLEAN_PROPERTY("hasIntl"); + +#ifdef NODE_HAVE_SMALL_ICU + READONLY_BOOLEAN_PROPERTY("hasSmallICU"); +#endif // NODE_HAVE_SMALL_ICU + + if (flag_icu_data_dir) + READONLY_BOOLEAN_PROPERTY("usingICUDataDir"); +#endif // NODE_HAVE_I18N_SUPPORT } } // namespace node diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 0f59b45c239..3e5b3a91298 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -42,10 +42,14 @@ extern "C" const char U_DATA_API SMALL_ICUDATA_ENTRY_POINT[]; #endif namespace node { + +bool flag_icu_data_dir = false; + namespace i18n { bool InitializeICUDirectory(const char* icu_data_path) { if (icu_data_path != nullptr) { + flag_icu_data_dir = true; u_setDataDirectory(icu_data_path); return true; // no error } else { diff --git a/src/node_i18n.h b/src/node_i18n.h index 0d47927a6c0..4e812ad0f3e 100644 --- a/src/node_i18n.h +++ b/src/node_i18n.h @@ -6,6 +6,9 @@ #if defined(NODE_HAVE_I18N_SUPPORT) namespace node { + +extern bool flag_icu_data_dir; + namespace i18n { bool InitializeICUDirectory(const char* icu_data_path);