From 43864d06d92f77f9a63dca76f1cf98cd4bfded65 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Tue, 13 May 2025 16:51:26 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/src/locale_config.cpp | 6 ++++++ frameworks/zone/test/unittest/zone_util_test.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index 9bb6cd31..11539d2a 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -67,6 +67,7 @@ const char *LocaleConfig::UPGRADE_LOCALE_KEY = "persist.global.upgrade_locale"; const char *LocaleConfig::DEFAULT_LOCALE_KEY = "const.global.locale"; const char *LocaleConfig::DEFAULT_LANGUAGE_KEY = "const.global.language"; const char *LocaleConfig::DEFAULT_REGION_KEY = "const.global.region"; +const char *LocaleConfig::DEVELOPER_MODE_KEY = "const.security.developermode.state"; const char *LocaleConfig::SIM_COUNTRY_CODE_KEY = "telephony.sim.countryCode0"; const char *LocaleConfig::SUPPORTED_LOCALES_NAME = "supported_locales"; const char *LocaleConfig::REGIONS_LANGUAGES_PATH = "etc/xml/i18n_param_config.xml"; @@ -566,6 +567,11 @@ const unordered_set& LocaleConfig::GetSupportedRegions() std::unordered_set LocaleConfig::GetSystemCountries(const std::string& language) { std::unordered_set result(supportedRegions); + std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY.c_str(), CONFIG_LEN); + if (developerMode.compare("true") == 0) { + result.insert("XA"); + result.insert("XB"); + } std::unordered_set blockedRegion = LocaleConfig::GetBlockedRegions(language); Expunge(result, blockedRegion); return result; diff --git a/frameworks/zone/test/unittest/zone_util_test.cpp b/frameworks/zone/test/unittest/zone_util_test.cpp index b281cb7c..e681bf2c 100644 --- a/frameworks/zone/test/unittest/zone_util_test.cpp +++ b/frameworks/zone/test/unittest/zone_util_test.cpp @@ -316,6 +316,9 @@ HWTEST_F(ZoneUtilTest, ZoneUtilFuncTest0012, TestSize.Level1) std::set timeZoneList = GetTimeZoneAvailableIDs(errorCode); std::unordered_set systemCountries = LocaleConfig::GetSystemCountries(); for (const auto& systemCountry : systemCountries) { + if (systemCountry.compare("XA") == 0 || systemCountry.compare("XB") == 0) { + continue; + } std::string timeZoneId = util.GetDefaultZone(systemCountry); EXPECT_TRUE(timeZoneList.find(timeZoneId) != timeZoneList.end()); if (timeZoneList.find(timeZoneId) == timeZoneList.end()) { -- Gitee From c7e53302a38e5967a1393f613a5bb92ebda95a44 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Tue, 13 May 2025 20:04:33 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/include/locale_config.h | 1 + frameworks/intl/src/locale_config.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/intl/include/locale_config.h b/frameworks/intl/include/locale_config.h index 7aae79b4..c3ea14d8 100644 --- a/frameworks/intl/include/locale_config.h +++ b/frameworks/intl/include/locale_config.h @@ -157,6 +157,7 @@ private: static const char *SUPPORT_LOCALES_PATH; static const char *SUPPORT_LOCALES_NAME; static const char *DEFAULT_LOCALE; + static const char *DEVELOPER_MODE_KEY; static const char *supportLocalesTag; static const char *LANG_PATH; static const char *rootTag; diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index 11539d2a..a5b58b77 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -567,7 +567,7 @@ const unordered_set& LocaleConfig::GetSupportedRegions() std::unordered_set LocaleConfig::GetSystemCountries(const std::string& language) { std::unordered_set result(supportedRegions); - std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY.c_str(), CONFIG_LEN); + std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY, CONFIG_LEN); if (developerMode.compare("true") == 0) { result.insert("XA"); result.insert("XB"); -- Gitee From 2b4e83aa24b5edbe1e92bb66969fe663b1366c14 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Wed, 14 May 2025 16:35:40 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/src/locale_config.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index a5b58b77..a63e27e3 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -544,6 +544,11 @@ void LocaleConfig::Split(const string &src, const string &sep, std::unordered_se std::unordered_set LocaleConfig::GetSystemLanguages() { std::unordered_set result(whiteLanguages); + std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY, CONFIG_LEN); + if (developerMode.compare("true") == 0) { + result.insert("en"); + result.insert("ar"); + } std::unordered_set blockedLanguages = GetBlockedLanguages(); Expunge(result, blockedLanguages); return result; -- Gitee From 62237fe4ee758c8370bf549fe6a0365790294e43 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Thu, 22 May 2025 14:13:01 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/src/locale_config.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index a63e27e3..c04ee187 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -546,7 +546,6 @@ std::unordered_set LocaleConfig::GetSystemLanguages() std::unordered_set result(whiteLanguages); std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY, CONFIG_LEN); if (developerMode.compare("true") == 0) { - result.insert("en"); result.insert("ar"); } std::unordered_set blockedLanguages = GetBlockedLanguages(); -- Gitee From 9089e0c1498ee7d0d73e880ea7bbeed3885ec623 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Fri, 23 May 2025 12:12:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/include/locale_config.h | 3 +++ frameworks/intl/src/locale_config.cpp | 26 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/frameworks/intl/include/locale_config.h b/frameworks/intl/include/locale_config.h index c3ea14d8..6721a7f7 100644 --- a/frameworks/intl/include/locale_config.h +++ b/frameworks/intl/include/locale_config.h @@ -183,6 +183,8 @@ private: static const std::string NUMBER_SYSTEM_KEY; static const std::string TEMPERATURE_UNIT_KEY; static const std::string WEEK_DAY_KEY; + static const std::string PSEUDO_REGION_XA; + static const std::string PSEUDO_REGION_XB; static const std::unordered_set& GetSupportedLocales(); static const std::unordered_set& GetSupportedLocalesV15(); @@ -209,6 +211,7 @@ private: static bool Is24HourLocale(const std::string& systemLocale); static bool HasDesignator(const std::string& inFormat, const char designator); static void QueryUpgradeLocale(); + static std::string GetPseudoCountryTag(const char* countryTag, std::string ®ionTag); #ifdef SUPPORT_GRAPHICS /** diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index c04ee187..83a7d172 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -97,6 +97,8 @@ const std::string LocaleConfig::TEMPERATURE_UNIT_KEY = "mu"; const std::string LocaleConfig::WEEK_DAY_KEY = "fw"; const std::string LocaleConfig::TIMEZONE_KEY = "persist.time.timezone"; const std::string LocaleConfig::DEFAULT_TIMEZONE = "GMT"; +const std::string LocaleConfig::PSEUDO_REGION_XA = "XA"; +const std::string LocaleConfig::PSEUDO_REGION_XB = "XB"; unordered_set LocaleConfig::supportedLocales; unordered_set LocaleConfig::supportedLocalesV15; unordered_set LocaleConfig::supportLocales; @@ -546,7 +548,8 @@ std::unordered_set LocaleConfig::GetSystemLanguages() std::unordered_set result(whiteLanguages); std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY, CONFIG_LEN); if (developerMode.compare("true") == 0) { - result.insert("ar"); + result.insert("en-XA"); + result.insert("ar-XB"); } std::unordered_set blockedLanguages = GetBlockedLanguages(); Expunge(result, blockedLanguages); @@ -571,11 +574,6 @@ const unordered_set& LocaleConfig::GetSupportedRegions() std::unordered_set LocaleConfig::GetSystemCountries(const std::string& language) { std::unordered_set result(supportedRegions); - std::string developerMode = ReadSystemParameter(DEVELOPER_MODE_KEY, CONFIG_LEN); - if (developerMode.compare("true") == 0) { - result.insert("XA"); - result.insert("XB"); - } std::unordered_set blockedRegion = LocaleConfig::GetBlockedRegions(language); Expunge(result, blockedRegion); return result; @@ -1754,6 +1752,8 @@ std::string LocaleConfig::UpdateLanguageOfLocale(const std::string &languageTag) return systemLocaleTag; } std::string regionTag = systemLocale.getCountry(); + const char* country = languageLocale.getCountry(); + regionTag = GetPseudoCountryTag(country, regionTag); std::string extendParamTag; size_t pos = systemLocaleTag.find(EXT_PARAM_KEY); if (pos != std::string::npos) { @@ -1763,6 +1763,20 @@ std::string LocaleConfig::UpdateLanguageOfLocale(const std::string &languageTag) return CreateLocale(langTag, scriptTag, regionTag, extendParamTag); } +std::string LocaleConfig::GetPseudoCountryTag(const char* countryTag, std::string ®ionTag) +{ + if (countryTag == nullptr) { + return regionTag; + } + if (PSEUDO_REGION_XA.compare(countryTag) == 0) { + return PSEUDO_REGION_XA; + } + if (PSEUDO_REGION_XB.compare(countryTag) == 0) { + return PSEUDO_REGION_XB; + } + return regionTag; +} + std::string LocaleConfig::CreateLocale(const std::string &languageTag, const std::string &scriptTag, const std::string ®ionTag, const std::string &extendParamTag) { -- Gitee From 9dc73b4d7137d9e647d89bdfc6292b68bf432112 Mon Sep 17 00:00:00 2001 From: zhangdd_ewan Date: Fri, 23 May 2025 12:14:34 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9=E4=BC=AA?= =?UTF-8?q?=E5=9C=B0=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdd_ewan --- frameworks/intl/src/locale_config.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/intl/src/locale_config.cpp b/frameworks/intl/src/locale_config.cpp index 83a7d172..6e851b76 100644 --- a/frameworks/intl/src/locale_config.cpp +++ b/frameworks/intl/src/locale_config.cpp @@ -1752,8 +1752,7 @@ std::string LocaleConfig::UpdateLanguageOfLocale(const std::string &languageTag) return systemLocaleTag; } std::string regionTag = systemLocale.getCountry(); - const char* country = languageLocale.getCountry(); - regionTag = GetPseudoCountryTag(country, regionTag); + regionTag = GetPseudoCountryTag(languageLocale.getCountry(), regionTag); std::string extendParamTag; size_t pos = systemLocaleTag.find(EXT_PARAM_KEY); if (pos != std::string::npos) { -- Gitee