!1922 修改切换繁体中国地区不显示繁体运营商名称

Merge pull request !1922 from dingxiaochen/master
This commit is contained in:
openharmony_ci 2024-05-22 07:29:05 +00:00 committed by Gitee
commit 5d4ce2b72f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -24,6 +24,7 @@
#include "cstring" #include "cstring"
#include "iosfwd" #include "iosfwd"
#include "locale_config.h" #include "locale_config.h"
#include "locale_info.h"
#include "memory" #include "memory"
#include "parameter.h" #include "parameter.h"
#include "telephony_errors.h" #include "telephony_errors.h"
@ -39,6 +40,7 @@ const char *ITEM_ZH_HANS_CN = "zh-Hans-CN";
const char *ITEM_EN_LATN_US = "en-Latn-US"; const char *ITEM_EN_LATN_US = "en-Latn-US";
const char *ITEM_ZH_HANT_TW = "zh-Hant-TW"; const char *ITEM_ZH_HANT_TW = "zh-Hant-TW";
const char *ITEM_ZH_HANT_HK = "zh-Hant-HK"; const char *ITEM_ZH_HANT_HK = "zh-Hant-HK";
const char *LANGUAGE_SCRIPT = "Hant";
const int MAX_BYTE_LEN = 10 * 1024 * 1024; const int MAX_BYTE_LEN = 10 * 1024 * 1024;
OperatorNameUtils &OperatorNameUtils::GetInstance() OperatorNameUtils &OperatorNameUtils::GetInstance()
@ -210,7 +212,14 @@ int32_t OperatorNameUtils::CloseFile(FILE *f) const
std::string OperatorNameUtils::GetNameByLocale(OperatorNameCust &value) std::string OperatorNameUtils::GetNameByLocale(OperatorNameCust &value)
{ {
std::string locale = OHOS::Global::I18n::LocaleConfig::GetSystemLocale(); std::string locale = OHOS::Global::I18n::LocaleConfig::GetSystemLocale();
TELEPHONY_LOGD("locale is %{public}s", locale.c_str()); OHOS::Global::I18n::LocaleInfo localeInfo(locale);
TELEPHONY_LOGD("locale is %{public}s, language is %{public}s, script is %{public}s, region is %{public}s",
locale.c_str(), localeInfo.GetLanguage().c_str(), localeInfo.GetScript().c_str(),
localeInfo.GetRegion().c_str());
if (localeInfo.GetScript() == std::string(LANGUAGE_SCRIPT)) {
locale = std::string(ITEM_ZH_HANT_HK);
}
if (locale == std::string(ITEM_ZH_HANS_CN)) { if (locale == std::string(ITEM_ZH_HANS_CN)) {
return value.zhHansCN; return value.zhHansCN;
} }