From fba23c2680fa5b7a12f17683da0e26614b08f871 Mon Sep 17 00:00:00 2001 From: hwzjq Date: Tue, 27 Jul 2021 22:55:21 +0800 Subject: [PATCH] for icu:::Locale Signed-off-by: hwzjq --- BUILD.gn | 4 ++-- adapter/ohos/cpp/BUILD.gn | 5 ++++- adapter/ohos/cpp/ace_ability.cpp | 7 +++--- adapter/ohos/cpp/ace_application_info.cpp | 2 +- .../bridge/card_frontend/js_card_parser.cpp | 22 +++++++++---------- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 8c10ac95..f08be373 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -60,8 +60,8 @@ config("ace_config") { ] if (is_standard_system) { include_dirs += [ - "//base/global/resmgr_standard/frameworks/resmgr/include", "//base/global/resmgr_standard/interfaces/innerkits/include", + "//third_party/icu/icu4c/source/common", ] } defines = ace_common_defines @@ -113,8 +113,8 @@ config("ace_test_config") { ] if (is_standard_system) { include_dirs += [ - "//base/global/resmgr_standard/frameworks/resmgr/include", "//base/global/resmgr_standard/interfaces/innerkits/include", + "//third_party/icu/icu4c/source/common", ] } defines = ace_common_defines diff --git a/adapter/ohos/cpp/BUILD.gn b/adapter/ohos/cpp/BUILD.gn index 6385a536..405ea88c 100644 --- a/adapter/ohos/cpp/BUILD.gn +++ b/adapter/ohos/cpp/BUILD.gn @@ -39,12 +39,15 @@ template("ace_base_platform_source_set") { deps = [ "$flutter_root:ace_skia_$platform", - "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr", "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", "//foundation/graphic/standard:libwms_client", "//third_party/zlib:libz", ] + public_deps = [ + "//base/global/resmgr_standard/frameworks/resmgr:global_resmgr", + ] + external_deps = [ "aafwk_standard:ability_manager", "aafwk_standard:want", diff --git a/adapter/ohos/cpp/ace_ability.cpp b/adapter/ohos/cpp/ace_ability.cpp index d6e6fa71..a0e73bed 100644 --- a/adapter/ohos/cpp/ace_ability.cpp +++ b/adapter/ohos/cpp/ace_ability.cpp @@ -23,7 +23,6 @@ #include "init_data.h" #include "touch_event.h" -#include "locale_info.h" #include "res_config.h" #include "resource_manager.h" @@ -127,9 +126,9 @@ void AceAbility::OnStart(const Want& want) auto localeInfo = resConfig->GetLocaleInfo(); AceApplicationInfo::GetInstance().SetResourceManager(resourceManager); if (localeInfo != nullptr) { - auto language = localeInfo->GetLanguage(); - auto region = localeInfo->GetRegion(); - auto script = localeInfo->GetScript(); + auto language = localeInfo->getLanguage(); + auto region = localeInfo->getCountry(); + auto script = localeInfo->getScript(); AceApplicationInfo::GetInstance().SetLocale( (language == nullptr) ? "" : language, (region == nullptr) ? "" : region, diff --git a/adapter/ohos/cpp/ace_application_info.cpp b/adapter/ohos/cpp/ace_application_info.cpp index c364cbf1..3026ad65 100755 --- a/adapter/ohos/cpp/ace_application_info.cpp +++ b/adapter/ohos/cpp/ace_application_info.cpp @@ -69,7 +69,7 @@ void AceApplicationInfoImpl::ChangeLocale(const std::string& language, const std return; } - auto script = localeInfo->GetScript(); + auto script = localeInfo->getScript(); resConfig->SetLocaleInfo(languageLower.c_str(), script, countryOrRegionUpper.c_str()); resourceManager_->UpdateResConfig(*resConfig); diff --git a/frameworks/bridge/card_frontend/js_card_parser.cpp b/frameworks/bridge/card_frontend/js_card_parser.cpp index 9a81f8a7..ac6c9895 100644 --- a/frameworks/bridge/card_frontend/js_card_parser.cpp +++ b/frameworks/bridge/card_frontend/js_card_parser.cpp @@ -33,8 +33,8 @@ const char BLOCK_VALUE[] = "blockValue"; const std::string REPEAT_INDEX = "$idx"; const std::string REPEAT_ITEM = "$item"; -const std::string TRUE = "true"; -const std::string FALSE = "false"; +const std::string TRUE_STR = "true"; +const std::string FALSE_STR = "false"; std::unique_ptr GetJsonValue( const std::vector& keys, const std::unique_ptr& fileData) @@ -599,7 +599,7 @@ bool JsCardParser::GetShownValue(std::string& value) return false; } } - value = showValue ? TRUE : FALSE; + value = showValue ? TRUE_STR : FALSE_STR; return true; } @@ -1147,11 +1147,11 @@ void JsCardParser::UpdateDomNode(const RefPtr& page, const auto attrCommand = Referenced::MakeRefPtr(selfId); auto ptr = Referenced::RawPtr(attrCommand); if (shouldShow && hasShownAttr) { - attrs.emplace_back(std::make_pair("show", TRUE)); + attrs.emplace_back(std::make_pair("show", TRUE_STR)); } ParseAttributes(rootJson, selfId, attrs, (JsCommandDomElementOperator*)ptr); if (!shouldShow && hasShownAttr) { - attrs.emplace_back(std::make_pair("show", FALSE)); + attrs.emplace_back(std::make_pair("show", FALSE_STR)); } ParseStyles(rootJson, selfId, styles); ParseEvents(rootJson, events, page, selfId); @@ -1211,7 +1211,7 @@ bool JsCardParser::ParseTernaryExpression(std::string& value) return false; } GetVariable(flagStr[0]); - auto flag = flagStr[0] == TRUE; + auto flag = flagStr[0] == TRUE_STR; std::vector keyStr; StringUtils::SplitStr(flagStr[1], ":", keyStr); @@ -1236,7 +1236,7 @@ bool JsCardParser::ParseLogicalExpression(std::string& value) } GetVariable(splitStr[0]); GetVariable(splitStr[1]); - value = (splitStr[0] == TRUE && splitStr[1] == TRUE) ? TRUE : FALSE; + value = (splitStr[0] == TRUE_STR && splitStr[1] == TRUE_STR) ? TRUE_STR : FALSE_STR; return true; } else if (value.find("||") != std::string::npos) { // for {{flag1 || flag2}}. @@ -1246,7 +1246,7 @@ bool JsCardParser::ParseLogicalExpression(std::string& value) } GetVariable(splitStr[0]); GetVariable(splitStr[1]); - value = (splitStr[0] == TRUE || splitStr[1] == TRUE) ? TRUE : FALSE; + value = (splitStr[0] == TRUE_STR || splitStr[1] == TRUE_STR) ? TRUE_STR : FALSE_STR; return true; } else if (value.find('!') != std::string::npos) { // for {{!flag1}}. @@ -1255,7 +1255,7 @@ bool JsCardParser::ParseLogicalExpression(std::string& value) return false; } GetVariable(splitStr[0]); - value = splitStr[0] == TRUE ? FALSE : TRUE; + value = splitStr[0] == TRUE_STR ? FALSE_STR : TRUE_STR; return true; } return false; @@ -1394,11 +1394,11 @@ void JsCardParser::CreateDomNode(const RefPtr& page, const command->SetPipelineContext(context_); auto ptr = Referenced::RawPtr(command); if (shouldShow && hasShownAttr) { - attrs.emplace_back(std::make_pair("show", TRUE)); + attrs.emplace_back(std::make_pair("show", TRUE_STR)); } ParseAttributes(rootJson, nodeId, attrs, (Framework::JsCommandDomElementOperator*)ptr); if (!shouldShow && hasShownAttr) { - attrs.emplace_back(std::make_pair("show", FALSE)); + attrs.emplace_back(std::make_pair("show", FALSE_STR)); } LOGD("card nodeId: %d, parentId: %d, type: %s", nodeId, parentId, type.c_str()); ParseStyles(rootJson, nodeId, styles);