From 410ff59ba5f6380b5a3926bcc88565c89787ed28 Mon Sep 17 00:00:00 2001 From: dinghong Date: Tue, 18 Mar 2025 15:08:21 +0800 Subject: [PATCH] fix i18n compatibility Signed-off-by: dinghong --- interfaces/cj/BUILD.gn | 96 ++++++++++++------------- interfaces/cj/cj_i18n_mock.cpp | 20 ------ interfaces/cj/include/i18n_system_ffi.h | 2 + interfaces/cj/src/i18n_system_ffi.cpp | 5 ++ 4 files changed, 53 insertions(+), 70 deletions(-) delete mode 100644 interfaces/cj/cj_i18n_mock.cpp diff --git a/interfaces/cj/BUILD.gn b/interfaces/cj/BUILD.gn index e4df42d3..b7c6de5b 100755 --- a/interfaces/cj/BUILD.gn +++ b/interfaces/cj/BUILD.gn @@ -31,56 +31,52 @@ ohos_shared_library("cj_i18n_ffi") { defines = [] } - if (!build_ohos_sdk) { - deps = [ - "../../frameworks/intl:intl_util", - "../../frameworks/intl:preferred_language", - ] - external_deps = [ - "c_utils:utils", - "common_event_service:cesfwk_innerkits", - "hilog:libhilog", - "icu:shared_icui18n", - "icu:shared_icuuc", - "ipc:ipc_core", - "libphonenumber:phonenumber_standard", - "libpng:libpng", - "libxml2:libxml2", - "napi:ace_napi", - "napi:cj_bind_ffi", - "napi:cj_bind_native", - "preferences:native_preferences", - "samgr:samgr_proxy", - ] - sources = [ - "src/i18n_breakIterator_ffi.cpp", - "src/i18n_breakIterator_impl.cpp", - "src/i18n_calendar_ffi.cpp", - "src/i18n_calendar_impl.cpp", - "src/i18n_entity_ffi.cpp", - "src/i18n_entity_impl.cpp", - "src/i18n_ffi.cpp", - "src/i18n_holiday_ffi.cpp", - "src/i18n_holiday_impl.cpp", - "src/i18n_index_util_ffi.cpp", - "src/i18n_index_util_impl.cpp", - "src/i18n_normalizer_ffi.cpp", - "src/i18n_normalizer_impl.cpp", - "src/i18n_phone_number_format_ffi.cpp", - "src/i18n_phone_number_format_impl.cpp", - "src/i18n_system_ffi.cpp", - "src/i18n_timezone_ffi.cpp", - "src/i18n_timezone_impl.cpp", - "src/i18n_transliterator_ffi.cpp", - "src/i18n_transliterator_impl.cpp", - "src/i18n_unicode_ffi.cpp", - "src/i18n_util_ffi.cpp", - ] - } else { - defines += [ "PREVIEWER" ] - sources = [ "cj_i18n_mock.cpp" ] - external_deps = [ "napi:cj_bind_ffi" ] - } + deps = [ + "../../frameworks/intl:intl_util", + "../../frameworks/intl:preferred_language", + ] + + external_deps = [ + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "hilog:libhilog", + "icu:shared_icui18n", + "icu:shared_icuuc", + "ipc:ipc_core", + "libphonenumber:phonenumber_standard", + "libpng:libpng", + "libxml2:libxml2", + "napi:ace_napi", + "napi:cj_bind_ffi", + "napi:cj_bind_native", + "preferences:native_preferences", + "samgr:samgr_proxy", + ] + + sources = [ + "src/i18n_breakIterator_ffi.cpp", + "src/i18n_breakIterator_impl.cpp", + "src/i18n_calendar_ffi.cpp", + "src/i18n_calendar_impl.cpp", + "src/i18n_entity_ffi.cpp", + "src/i18n_entity_impl.cpp", + "src/i18n_ffi.cpp", + "src/i18n_holiday_ffi.cpp", + "src/i18n_holiday_impl.cpp", + "src/i18n_index_util_ffi.cpp", + "src/i18n_index_util_impl.cpp", + "src/i18n_normalizer_ffi.cpp", + "src/i18n_normalizer_impl.cpp", + "src/i18n_phone_number_format_ffi.cpp", + "src/i18n_phone_number_format_impl.cpp", + "src/i18n_system_ffi.cpp", + "src/i18n_timezone_ffi.cpp", + "src/i18n_timezone_impl.cpp", + "src/i18n_transliterator_ffi.cpp", + "src/i18n_transliterator_impl.cpp", + "src/i18n_unicode_ffi.cpp", + "src/i18n_util_ffi.cpp", + ] if (current_os == "ohos") { defines += [ "OHOS_PLATFORM" ] diff --git a/interfaces/cj/cj_i18n_mock.cpp b/interfaces/cj/cj_i18n_mock.cpp deleted file mode 100644 index b7384619..00000000 --- a/interfaces/cj/cj_i18n_mock.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "cj_common_ffi.h" - -extern "C" { -FFI_EXPORT int FfiOHOSGetAppPreferredLanguage = 0; -} \ No newline at end of file diff --git a/interfaces/cj/include/i18n_system_ffi.h b/interfaces/cj/include/i18n_system_ffi.h index 4b798b7c..39d6624e 100644 --- a/interfaces/cj/include/i18n_system_ffi.h +++ b/interfaces/cj/include/i18n_system_ffi.h @@ -22,6 +22,8 @@ #define FFI_EXPORT __attribute__((visibility("default"))) extern "C" { + FFI_EXPORT char* FfiOHOSGetAppPreferredLanguage(); + FFI_EXPORT char* FfiI18nSystemGetAppPreferredLanguage(); FFI_EXPORT char* FfiI18nSystemGetSystemLanguage(); FFI_EXPORT char* FfiI18nSystemGetSystemRegion(); diff --git a/interfaces/cj/src/i18n_system_ffi.cpp b/interfaces/cj/src/i18n_system_ffi.cpp index 074fac79..842171ea 100644 --- a/interfaces/cj/src/i18n_system_ffi.cpp +++ b/interfaces/cj/src/i18n_system_ffi.cpp @@ -32,6 +32,11 @@ namespace I18n { using namespace OHOS::HiviewDFX; extern "C" { + char* FfiOHOSGetAppPreferredLanguage() + { + return FfiI18nSystemGetAppPreferredLanguage(); + } + char* FfiI18nSystemGetAppPreferredLanguage() { #ifdef SUPPORT_APP_PREFERRED_LANGUAGE -- Gitee