mirror of
https://gitee.com/openharmony/global_i18n
synced 2024-11-23 23:21:42 +00:00
fix conflicts
Signed-off-by: zhangdd_ewan <zhangdongdong13@h-partners.com>
This commit is contained in:
commit
626246393e
@ -85,10 +85,13 @@ ohos_shared_library("intl_util") {
|
||||
deps = [
|
||||
":config_locales_xml",
|
||||
":config_regions_xml",
|
||||
":en_Latn_timezone_xml",
|
||||
":forbidden_languages_xml",
|
||||
":forbidden_regions_xml",
|
||||
":language_config.para",
|
||||
":timezone_supported_locales",
|
||||
":white_languages_xml",
|
||||
":zh_Hans_timezone_xml",
|
||||
"//third_party/icu/icu4c:ohos_icudat",
|
||||
"//third_party/icu/icu4c:shared_icui18n",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
@ -151,3 +154,25 @@ ohos_prebuilt_etc("forbidden_regions_xml") {
|
||||
part_name = "i18n"
|
||||
subsystem_name = "global"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("zh_Hans_timezone_xml") {
|
||||
source = "//base/global/i18n/frameworks/intl/etc/timezone/zh-Hans.xml"
|
||||
module_install_dir = "usr/ohos_timezone/"
|
||||
part_name = "i18n"
|
||||
subsystem_name = "global"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("en_Latn_timezone_xml") {
|
||||
source = "//base/global/i18n/frameworks/intl/etc/timezone/en-Latn.xml"
|
||||
module_install_dir = "usr/ohos_timezone/"
|
||||
part_name = "i18n"
|
||||
subsystem_name = "global"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("timezone_supported_locales") {
|
||||
source =
|
||||
"//base/global/i18n/frameworks/intl/etc/timezone/supported_locales.xml"
|
||||
module_install_dir = "usr/ohos_timezone/"
|
||||
part_name = "i18n"
|
||||
subsystem_name = "global"
|
||||
}
|
||||
|
136
frameworks/intl/etc/timezone/en-Latn.xml
Normal file
136
frameworks/intl/etc/timezone/en-Latn.xml
Normal file
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 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.
|
||||
-->
|
||||
<timezones>
|
||||
<timezone>
|
||||
<city>Auckland</city>
|
||||
<id>Pacific/Auckland</id>
|
||||
<display_name>Auckland (New Zealand)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Magadan</city>
|
||||
<id>Asia/Magadan</id>
|
||||
<display_name>Magadan (Russia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Lord Howe Island</city>
|
||||
<id>Australia/Lord_Howe</id>
|
||||
<display_name>Lord Howe Island (Australia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Tokyo</city>
|
||||
<id>Asia/Tokyo</id>
|
||||
<display_name>Tokyo (Japan)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Shanghai</city>
|
||||
<id>Asia/Shanghai</id>
|
||||
<display_name>Shanghai (China)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Hovd</city>
|
||||
<id>Asia/Hovd</id>
|
||||
<display_name>Khovd (Mongolia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Omsk</city>
|
||||
<id>Asia/Omsk</id>
|
||||
<display_name>Omsk (Russia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Ashgabat</city>
|
||||
<id>Asia/Ashgabat</id>
|
||||
<display_name>Ashgabat (Turkmenistan)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Yerevan</city>
|
||||
<id>Asia/Yerevan</id>
|
||||
<display_name>Yerevan (Armenia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Moscow</city>
|
||||
<id>Europe/Moscow</id>
|
||||
<display_name>Moscow (Russia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Tel Aviv</city>
|
||||
<id>Asia/Jerusalem</id>
|
||||
<display_name>Tel Aviv (Israel)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Dublin</city>
|
||||
<id>Europe/Dublin</id>
|
||||
<display_name>Dublin (Ireland)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>London</city>
|
||||
<id>Europe/London</id>
|
||||
<display_name>London (United Kingdom)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Praia</city>
|
||||
<id>Atlantic/Cape_Verde</id>
|
||||
<display_name>Praia (Cape Verde)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Montevideo</city>
|
||||
<id>America/Montevideo</id>
|
||||
<display_name>Montevideo (Uruguay)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Brasília</city>
|
||||
<id>America/Sao_Paulo</id>
|
||||
<display_name>Brasília (Brazil)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Stanley</city>
|
||||
<id>Atlantic/Stanley</id>
|
||||
<display_name>Stanley (Falkland Islands)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Bogotá</city>
|
||||
<id>America/Bogota</id>
|
||||
<display_name>Bogotá (Colombia)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Easter Island</city>
|
||||
<id>Pacific/Easter</id>
|
||||
<display_name>Easter Island (Chile)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Salt Lake City</city>
|
||||
<id>America/Denver</id>
|
||||
<display_name>Salt Lake City (United States)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Los Angeles</city>
|
||||
<id>America/Los_Angeles</id>
|
||||
<display_name>Los Angeles (United States)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Anchorage</city>
|
||||
<id>America/Anchorage</id>
|
||||
<display_name>Anchorage (United States)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Adak</city>
|
||||
<id>America/Adak</id>
|
||||
<display_name>Adak (United States)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Pago Pago</city>
|
||||
<id>Pacific/Pago-Pago</id>
|
||||
<display_name>Pago Pago (American Samoa)</display_name>
|
||||
</timezone>
|
||||
</timezones>
|
18
frameworks/intl/etc/timezone/supported_locales.xml
Normal file
18
frameworks/intl/etc/timezone/supported_locales.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2021 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.
|
||||
-->
|
||||
<supported_locales>
|
||||
<item>en-Latn</item>
|
||||
<item>zh-Hans</item>
|
||||
</supported_locales>
|
136
frameworks/intl/etc/timezone/zh-Hans.xml
Normal file
136
frameworks/intl/etc/timezone/zh-Hans.xml
Normal file
@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 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.
|
||||
-->
|
||||
<timezones>
|
||||
<timezone>
|
||||
<city>Auckland</city>
|
||||
<id>Pacific/Auckland</id>
|
||||
<display_name>奥克兰 (新西兰)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Magadan</city>
|
||||
<id>Asia/Magadan</id>
|
||||
<display_name>马加丹 (俄罗斯)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Lord Howe Island</city>
|
||||
<id>Australia/Lord_Howe</id>
|
||||
<display_name>豪勋爵岛 (澳大利亚)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Tokyo</city>
|
||||
<id>Asia/Tokyo</id>
|
||||
<display_name>东京 (日本)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Shanghai</city>
|
||||
<id>Asia/Shanghai</id>
|
||||
<display_name>上海 (中国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Hovd</city>
|
||||
<id>Asia/Hovd</id>
|
||||
<display_name>科布多 (蒙古)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Omsk</city>
|
||||
<id>Asia/Omsk</id>
|
||||
<display_name>鄂木斯克 (俄罗斯)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Ashgabat</city>
|
||||
<id>Asia/Ashgabat</id>
|
||||
<display_name>阿什哈巴德 (土库曼斯坦)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Yerevan</city>
|
||||
<id>Asia/Yerevan</id>
|
||||
<display_name>埃里温 (亚美尼亚)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Moscow</city>
|
||||
<id>Europe/Moscow</id>
|
||||
<display_name>莫斯科 (俄罗斯)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Tel Aviv</city>
|
||||
<id>Asia/Jerusalem</id>
|
||||
<display_name>特拉维夫 (以色列)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Dublin</city>
|
||||
<id>Europe/Dublin</id>
|
||||
<display_name>都柏林 (爱尔兰)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>London</city>
|
||||
<id>Europe/London</id>
|
||||
<display_name>伦敦 (英国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Praia</city>
|
||||
<id>Atlantic/Cape_Verde</id>
|
||||
<display_name>普拉亚 (佛得角)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Montevideo</city>
|
||||
<id>America/Montevideo</id>
|
||||
<display_name>蒙得维的亚 (乌拉圭)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Brasília</city>
|
||||
<id>America/Sao_Paulo</id>
|
||||
<display_name>巴西利亚 (巴西)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Stanley</city>
|
||||
<id>Atlantic/Stanley</id>
|
||||
<display_name>史丹利 (福克兰群岛)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Bogotá</city>
|
||||
<id>America/Bogota</id>
|
||||
<display_name>波哥大 (哥伦比亚)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Easter Island</city>
|
||||
<id>Pacific/Easter</id>
|
||||
<display_name>复活节岛 (智利)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Salt Lake City</city>
|
||||
<id>America/Denver</id>
|
||||
<display_name>盐湖城 (美国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Los Angeles</city>
|
||||
<id>America/Los_Angeles</id>
|
||||
<display_name>洛杉矶 (美国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Anchorage</city>
|
||||
<id>America/Anchorage</id>
|
||||
<display_name>安克雷奇 (美国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Adak</city>
|
||||
<id>America/Adak</id>
|
||||
<display_name>埃达克 (美国)</display_name>
|
||||
</timezone>
|
||||
<timezone>
|
||||
<city>Pago Pago</city>
|
||||
<id>Pacific/Pago-Pago</id>
|
||||
<display_name>帕果-帕果 (美属萨摩耶)</display_name>
|
||||
</timezone>
|
||||
</timezones>
|
@ -15,7 +15,10 @@
|
||||
#ifndef OHOS_GLOBAL_I18N_TIMEZONE_H
|
||||
#define OHOS_GLOBAL_I18N_TIMEZONE_H
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "unicode/timezone.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -23,7 +26,7 @@ namespace Global {
|
||||
namespace I18n {
|
||||
class I18nTimeZone {
|
||||
public:
|
||||
I18nTimeZone(std::string zoneID);
|
||||
I18nTimeZone(std::string &id, bool isZoneID);
|
||||
~I18nTimeZone();
|
||||
int32_t GetOffset(double date);
|
||||
int32_t GetRawOffset();
|
||||
@ -32,9 +35,29 @@ public:
|
||||
std::string GetDisplayName(bool isDST);
|
||||
std::string GetDisplayName(std::string localeStr);
|
||||
std::string GetDisplayName(std::string localeStr, bool isDST);
|
||||
static std::unique_ptr<I18nTimeZone> CreateInstance(std::string zoneID);
|
||||
static std::unique_ptr<I18nTimeZone> CreateInstance(std::string &id, bool isZoneID);
|
||||
static std::set<std::string> GetAvailableIDs();
|
||||
static std::vector<std::string> GetAvailableZoneCityIDs();
|
||||
static std::string GetCityDisplayName(std::string &cityID, std::string &locale);
|
||||
|
||||
private:
|
||||
static const char *DEFAULT_LANGUAGE;
|
||||
static const char *DEFAULT_LOCALE;
|
||||
static const char *TIMEZONES_PATH;
|
||||
static const char *SUPPORT_LOCALES_PATH;
|
||||
static const char *rootTag;
|
||||
static const char *secondRootTag;
|
||||
static const uint32_t ELEMENT_NUM = 3;
|
||||
static const char *supportLocalesTag;
|
||||
static std::string displayLocale;
|
||||
static bool isInitialized;
|
||||
static std::set<std::string> availableIDs;
|
||||
static std::vector<std::string> availableZoneCityIDs;
|
||||
static std::map<std::string, std::string> city2DisplayName;
|
||||
static std::map<std::string, std::string> city2TimeZoneID;
|
||||
static std::map<std::string, std::string> supportLocales;
|
||||
static void ReadTimeZoneData(const char *xmlPath);
|
||||
static std::string ComputeLocale(std::string &locale);
|
||||
icu::TimeZone* GetTimeZone();
|
||||
icu::TimeZone *timezone;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@ namespace Global {
|
||||
namespace I18n {
|
||||
class LocaleInfo {
|
||||
public:
|
||||
explicit LocaleInfo(std::string locale);
|
||||
explicit LocaleInfo(const std::string &locale);
|
||||
LocaleInfo(const std::string &localeTag, std::map<std::string, std::string> &configs);
|
||||
virtual ~LocaleInfo();
|
||||
std::string GetLanguage() const;
|
||||
|
@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "date_time_format.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "ohos/init_data.h"
|
||||
#include "locale_config.h"
|
||||
|
||||
|
@ -13,7 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "libxml/parser.h"
|
||||
#include "locale_config.h"
|
||||
#include "locale_info.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "i18n_timezone.h"
|
||||
@ -21,13 +23,43 @@
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
I18nTimeZone::I18nTimeZone(std::string zoneID)
|
||||
const char *I18nTimeZone::DEFAULT_LANGUAGE = "/system/usr/ohos_timezone/en-Latn.xml";
|
||||
const char *I18nTimeZone::DEFAULT_LOCALE = "en-Latn";
|
||||
const char *I18nTimeZone::TIMEZONES_PATH = "/system/usr/ohos_timezone/";
|
||||
const char *I18nTimeZone::SUPPORT_LOCALES_PATH = "/system/usr/ohos_timezone/supported_locales.xml";
|
||||
const char *I18nTimeZone::rootTag = "timezones";
|
||||
const char *I18nTimeZone::secondRootTag = "timezone";
|
||||
const char *I18nTimeZone::supportLocalesTag = "supported_locales";
|
||||
std::string I18nTimeZone::displayLocale = "";
|
||||
bool I18nTimeZone::isInitialized = false;
|
||||
|
||||
std::map<std::string, std::string> I18nTimeZone::supportLocales {};
|
||||
std::set<std::string> I18nTimeZone::availableIDs {};
|
||||
std::vector<std::string> I18nTimeZone::availableZoneCityIDs {};
|
||||
std::map<std::string, std::string> I18nTimeZone::city2DisplayName {};
|
||||
std::map<std::string, std::string> I18nTimeZone::city2TimeZoneID {};
|
||||
|
||||
I18nTimeZone::I18nTimeZone(std::string &id, bool isZoneID)
|
||||
{
|
||||
if (zoneID.empty()) {
|
||||
timezone = icu::TimeZone::createDefault();
|
||||
if (isZoneID) {
|
||||
if (id.empty()) {
|
||||
timezone = icu::TimeZone::createDefault();
|
||||
} else {
|
||||
icu::UnicodeString unicodeZoneID(id.data(), id.length());
|
||||
timezone = icu::TimeZone::createTimeZone(unicodeZoneID);
|
||||
}
|
||||
} else {
|
||||
icu::UnicodeString unicodeZoneID(zoneID.data(), zoneID.length());
|
||||
timezone = icu::TimeZone::createTimeZone(unicodeZoneID);
|
||||
if (!isInitialized) {
|
||||
ReadTimeZoneData(DEFAULT_LANGUAGE);
|
||||
isInitialized = true;
|
||||
}
|
||||
if (city2TimeZoneID.find(id) == city2TimeZoneID.end()) {
|
||||
timezone = icu::TimeZone::createDefault();
|
||||
} else {
|
||||
std::string timezoneID = city2TimeZoneID.at(id);
|
||||
icu::UnicodeString unicodeZoneID(timezoneID.data(), timezoneID.length());
|
||||
timezone = icu::TimeZone::createTimeZone(unicodeZoneID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,9 +76,9 @@ icu::TimeZone* I18nTimeZone::GetTimeZone()
|
||||
return timezone;
|
||||
}
|
||||
|
||||
std::unique_ptr<I18nTimeZone> I18nTimeZone::CreateInstance(std::string zoneID)
|
||||
std::unique_ptr<I18nTimeZone> I18nTimeZone::CreateInstance(std::string &id, bool isZoneID)
|
||||
{
|
||||
std::unique_ptr<I18nTimeZone> i18nTimeZone = std::make_unique<I18nTimeZone>(zoneID);
|
||||
std::unique_ptr<I18nTimeZone> i18nTimeZone = std::make_unique<I18nTimeZone>(id, isZoneID);
|
||||
if (i18nTimeZone->GetTimeZone() == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -107,6 +139,134 @@ std::string I18nTimeZone::GetDisplayName(std::string localeStr, bool isDST)
|
||||
name.toUTF8String(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void I18nTimeZone::ReadTimeZoneData(const char *xmlPath)
|
||||
{
|
||||
xmlKeepBlanksDefault(0);
|
||||
if (xmlPath == nullptr) {
|
||||
return;
|
||||
}
|
||||
xmlDocPtr doc = xmlParseFile(xmlPath);
|
||||
if (!doc) {
|
||||
return;
|
||||
}
|
||||
xmlNodePtr cur = xmlDocGetRootElement(doc);
|
||||
if (!cur || xmlStrcmp(cur->name, reinterpret_cast<const xmlChar *>(rootTag))) {
|
||||
xmlFreeDoc(doc);
|
||||
return;
|
||||
}
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != nullptr && !xmlStrcmp(cur->name, reinterpret_cast<const xmlChar *>(secondRootTag))) {
|
||||
xmlNodePtr value = cur->xmlChildrenNode;
|
||||
xmlChar *contents[ELEMENT_NUM] = { 0 }; // 3 represent cityid, zoneid, displayname;
|
||||
for (size_t i = 0; i < ELEMENT_NUM; i++) {
|
||||
if (value != nullptr) {
|
||||
contents[i] = xmlNodeGetContent(value);
|
||||
value = value->next;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isInitialized) {
|
||||
// 0 represents cityid index, 1 represents zoneid index
|
||||
availableZoneCityIDs.insert(availableZoneCityIDs.end(), reinterpret_cast<const char *>(contents[0]));
|
||||
availableIDs.insert(reinterpret_cast<const char *>(contents[1]));
|
||||
city2TimeZoneID.insert(
|
||||
std::make_pair<std::string, std::string>(reinterpret_cast<const char *>(contents[0]),
|
||||
reinterpret_cast<const char *>(contents[1])));
|
||||
}
|
||||
// 0 represents cityid index, 2 represents displayname index
|
||||
city2DisplayName.insert(
|
||||
std::make_pair<std::string, std::string>(reinterpret_cast<const char *>(contents[0]),
|
||||
reinterpret_cast<const char *>(contents[2])));
|
||||
for (size_t i = 0; i < ELEMENT_NUM; i++) {
|
||||
if (contents[i] != nullptr) {
|
||||
xmlFree(contents[i]);
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
xmlFreeDoc(doc);
|
||||
}
|
||||
|
||||
std::set<std::string> I18nTimeZone::GetAvailableIDs()
|
||||
{
|
||||
if (!isInitialized) {
|
||||
ReadTimeZoneData(DEFAULT_LANGUAGE);
|
||||
isInitialized = true;
|
||||
}
|
||||
return availableIDs;
|
||||
}
|
||||
|
||||
std::vector<std::string> I18nTimeZone::GetAvailableZoneCityIDs()
|
||||
{
|
||||
if (!isInitialized) {
|
||||
ReadTimeZoneData(DEFAULT_LANGUAGE);
|
||||
isInitialized = true;
|
||||
}
|
||||
return availableZoneCityIDs;
|
||||
}
|
||||
|
||||
std::string I18nTimeZone::ComputeLocale(std::string &locale)
|
||||
{
|
||||
if (supportLocales.size() == 0) {
|
||||
xmlKeepBlanksDefault(0);
|
||||
xmlDocPtr doc = xmlParseFile(SUPPORT_LOCALES_PATH);
|
||||
if (!doc) {
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
xmlNodePtr cur = xmlDocGetRootElement(doc);
|
||||
if (!cur || xmlStrcmp(cur->name, reinterpret_cast<const xmlChar *>(supportLocalesTag))) {
|
||||
xmlFreeDoc(doc);
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
cur = cur->xmlChildrenNode;
|
||||
while (cur != nullptr) {
|
||||
xmlChar *content = xmlNodeGetContent(cur);
|
||||
if (content == nullptr) {
|
||||
break;
|
||||
}
|
||||
std::map<std::string, std::string> configs = {};
|
||||
LocaleInfo localeinfo(reinterpret_cast<const char*>(content), configs);
|
||||
std::string language = localeinfo.GetLanguage();
|
||||
std::string script = localeinfo.GetScript();
|
||||
std::string languageAndScript = (script.length() == 0) ? language : language + "-" + script;
|
||||
LocaleInfo newLocaleInfo(languageAndScript, configs);
|
||||
std::string maximizeLocale = newLocaleInfo.Maximize();
|
||||
supportLocales.insert(
|
||||
std::make_pair<std::string, std::string>(maximizeLocale.c_str(),
|
||||
reinterpret_cast<const char*>(content)));
|
||||
xmlFree(content);
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
std::map<std::string, std::string> configs = {};
|
||||
LocaleInfo localeinfo(locale, configs);
|
||||
std::string language = localeinfo.GetLanguage();
|
||||
std::string script = localeinfo.GetScript();
|
||||
std::string languageAndScript = (script.length() == 0) ? language : language + "-" + script;
|
||||
LocaleInfo newLocaleInfo(languageAndScript, configs);
|
||||
std::string maximizeLocale = newLocaleInfo.Maximize();
|
||||
if (supportLocales.find(maximizeLocale) != supportLocales.end()) {
|
||||
return supportLocales.at(maximizeLocale);
|
||||
}
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
std::string I18nTimeZone::GetCityDisplayName(std::string &cityID, std::string &locale)
|
||||
{
|
||||
std::string finalLocale = ComputeLocale(locale);
|
||||
if (finalLocale.compare(displayLocale) != 0) {
|
||||
std::string xmlPath = TIMEZONES_PATH + finalLocale + ".xml";
|
||||
city2DisplayName.clear();
|
||||
ReadTimeZoneData(xmlPath.c_str());
|
||||
displayLocale = finalLocale;
|
||||
}
|
||||
if (city2DisplayName.find(cityID) == city2DisplayName.end()) {
|
||||
return "";
|
||||
}
|
||||
return city2DisplayName.at(cityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "locale_info.h"
|
||||
#include <algorithm>
|
||||
#include "ohos/init_data.h"
|
||||
#include "locale_config.h"
|
||||
|
||||
@ -21,7 +20,6 @@ namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
using namespace icu;
|
||||
|
||||
std::set<std::string> LocaleInfo::allValidLocales = GetValidLocales();
|
||||
|
||||
std::set<std::string> LocaleInfo::GetValidLocales()
|
||||
@ -38,7 +36,7 @@ std::set<std::string> LocaleInfo::GetValidLocales()
|
||||
return allValidLocales;
|
||||
}
|
||||
|
||||
LocaleInfo::LocaleInfo(std::string localeTag)
|
||||
LocaleInfo::LocaleInfo(const std::string &localeTag)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
configs = {};
|
||||
|
@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "number_format.h"
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "ohos/init_data.h"
|
||||
#include "locale_config.h"
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
#include "locale_config.h"
|
||||
#include "ohos/init_data.h"
|
||||
#include "relative_time_format.h"
|
||||
|
@ -16,23 +16,23 @@
|
||||
#ifndef OHOS_GLOBAL_I18N_INTL_TEST_H
|
||||
#define OHOS_GLOBAL_I18N_INTL_TEST_H
|
||||
|
||||
int IntlFuncTest001();
|
||||
int IntlFuncTest002();
|
||||
int IntlFuncTest003();
|
||||
int IntlFuncTest004();
|
||||
int IntlFuncTest005();
|
||||
int IntlFuncTest006();
|
||||
int IntlFuncTest007();
|
||||
int IntlFuncTest008();
|
||||
int IntlFuncTest009();
|
||||
int IntlFuncTest0010();
|
||||
int IntlFuncTest0011();
|
||||
int IntlFuncTest0012();
|
||||
int IntlFuncTest0013();
|
||||
int IntlFuncTest0014();
|
||||
int IntlFuncTest0015();
|
||||
int IntlFuncTest0016();
|
||||
int IntlFuncTest0017();
|
||||
int IntlFuncTest0018();
|
||||
int IntlFuncTest0019();
|
||||
int IntlFuncTest001(void);
|
||||
int IntlFuncTest002(void);
|
||||
int IntlFuncTest003(void);
|
||||
int IntlFuncTest004(void);
|
||||
int IntlFuncTest005(void);
|
||||
int IntlFuncTest006(void);
|
||||
int IntlFuncTest007(void);
|
||||
int IntlFuncTest008(void);
|
||||
int IntlFuncTest009(void);
|
||||
int IntlFuncTest0010(void);
|
||||
int IntlFuncTest0011(void);
|
||||
int IntlFuncTest0012(void);
|
||||
int IntlFuncTest0013(void);
|
||||
int IntlFuncTest0014(void);
|
||||
int IntlFuncTest0015(void);
|
||||
int IntlFuncTest0016(void);
|
||||
int IntlFuncTest0017(void);
|
||||
int IntlFuncTest0018(void);
|
||||
int IntlFuncTest0019(void);
|
||||
#endif
|
@ -14,8 +14,6 @@
|
||||
*/
|
||||
|
||||
#include "zone_util.h"
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include "ohos/init_data.h"
|
||||
#include "strenum.h"
|
||||
#include "unicode/timezone.h"
|
||||
|
@ -16,10 +16,10 @@
|
||||
#ifndef OHOS_GLOBAL_I18N_ZONE_UTIL_PERFORMANCE_TEST_H
|
||||
#define OHOS_GLOBAL_I18N_ZONE_UTIL_PERFORMANCE_TEST_H
|
||||
|
||||
int ZoneUtilPerformanceFuncTest001();
|
||||
int ZoneUtilPerformanceFuncTest002();
|
||||
int ZoneUtilPerformanceFuncTest003();
|
||||
int ZoneUtilPerformanceFuncTest004();
|
||||
int ZoneUtilPerformanceFuncTest005();
|
||||
int ZoneUtilPerformanceFuncTest006();
|
||||
int ZoneUtilPerformanceFuncTest001(void);
|
||||
int ZoneUtilPerformanceFuncTest002(void);
|
||||
int ZoneUtilPerformanceFuncTest003(void);
|
||||
int ZoneUtilPerformanceFuncTest004(void);
|
||||
int ZoneUtilPerformanceFuncTest005(void);
|
||||
int ZoneUtilPerformanceFuncTest006(void);
|
||||
#endif
|
@ -16,12 +16,12 @@
|
||||
#ifndef OHOS_GLOBAL_I18N_ZONE_UTIL_TEST_H
|
||||
#define OHOS_GLOBAL_I18N_ZONE_UTIL_TEST_H
|
||||
|
||||
int ZoneUtilFuncTest001();
|
||||
int ZoneUtilFuncTest002();
|
||||
int ZoneUtilFuncTest003();
|
||||
int ZoneUtilFuncTest004();
|
||||
int ZoneUtilFuncTest005();
|
||||
int ZoneUtilFuncTest006();
|
||||
int ZoneUtilFuncTest007();
|
||||
int ZoneUtilFuncTest008();
|
||||
int ZoneUtilFuncTest001(void);
|
||||
int ZoneUtilFuncTest002(void);
|
||||
int ZoneUtilFuncTest003(void);
|
||||
int ZoneUtilFuncTest004(void);
|
||||
int ZoneUtilFuncTest005(void);
|
||||
int ZoneUtilFuncTest006(void);
|
||||
int ZoneUtilFuncTest007(void);
|
||||
int ZoneUtilFuncTest008(void);
|
||||
#endif
|
@ -1,169 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 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.
|
||||
*/
|
||||
#ifndef I18N_ADDON_H
|
||||
#define I18N_ADDON_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "napi/native_api.h"
|
||||
#include "i18n_break_iterator.h"
|
||||
#include "i18n_calendar.h"
|
||||
#include "i18n_timezone.h"
|
||||
#include "index_util.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "locale_config.h"
|
||||
#include "measure_data.h"
|
||||
#include "number_format.h"
|
||||
#include "phone_number_format.h"
|
||||
#include "preferred_language.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
void GetOptionMap(napi_env env, napi_value argv, std::map<std::string, std::string> &map);
|
||||
void GetOptionValue(napi_env env, napi_value options, const std::string &optionName,
|
||||
std::string &value);
|
||||
|
||||
class I18nAddon {
|
||||
public:
|
||||
static napi_value Init(napi_env env, napi_value exports);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
I18nAddon();
|
||||
virtual ~I18nAddon();
|
||||
static napi_value GetSystemLanguages(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemCountries(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSuggested(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayCountry(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemRegion(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemRegion(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRTL(napi_env env, napi_callback_info info);
|
||||
static napi_value InitPhoneNumberFormat(napi_env env, napi_value exports);
|
||||
static napi_value InitI18nCalendar(napi_env env, napi_value exports);
|
||||
static napi_value UnitConvert(napi_env env, napi_callback_info info);
|
||||
static napi_value InitBreakIterator(napi_env env, napi_value exports);
|
||||
static napi_value InitIndexUtil(napi_env env, napi_value exports);
|
||||
static napi_value IsDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSpaceCharAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsWhiteSpaceAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRTLCharacterAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsIdeoGraphicAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsLetterAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsLowerCaseAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsUpperCaseAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTypeAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value Is24HourClock(napi_env env, napi_callback_info info);
|
||||
static napi_value Set24HourClock(napi_env env, napi_callback_info info);
|
||||
static napi_value AddPreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value RemovePreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetPreferredLanguageList(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFirstPreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value InitI18nTimeZone(napi_env env, napi_value exports);
|
||||
static napi_value GetI18nTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDateOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value InitTransliterator(napi_env env, napi_value exports);
|
||||
static napi_value GetTransliteratorInstance(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value SetUsingLocalDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetUsingLocalDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableTimezoneIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableZoneCityIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetCityDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTimezoneFromCity(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
static void CreateInitProperties(napi_property_descriptor *properties);
|
||||
static napi_value PhoneNumberFormatConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value IsValidPhoneNumber(napi_env env, napi_callback_info info);
|
||||
static napi_value FormatPhoneNumber(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLocationName(napi_env env, napi_callback_info info);
|
||||
bool InitPhoneNumberFormatContext(napi_env env, napi_callback_info info, const std::string &country,
|
||||
const std::map<std::string, std::string> &options);
|
||||
|
||||
static napi_value CalendarConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value BreakIteratorConstructor(napi_env env, napi_callback_info info);
|
||||
bool InitCalendarContext(napi_env env, napi_callback_info info, const std::string &localeTag, CalendarType type);
|
||||
static napi_value GetCalendar(napi_env env, napi_callback_info info);
|
||||
static napi_value Set(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDate(napi_env env, napi_value value);
|
||||
void SetMilliseconds(napi_env env, napi_value value);
|
||||
void SetField(napi_env env, napi_value value, UCalendarDateFields field);
|
||||
static napi_value SetTime(napi_env env, napi_callback_info info);
|
||||
static std::string GetString(napi_env &env, napi_value &value, int32_t &code);
|
||||
static napi_value SetTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value SetFirstDayOfWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFirstDayOfWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value SetMinimalDaysInFirstWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value GetMinimalDaysInFirstWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value Get(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value IsWeekend(napi_env env, napi_callback_info info);
|
||||
static CalendarType GetCalendarType(napi_env env, napi_value value);
|
||||
static napi_value GetLineInstance(napi_env env, napi_callback_info info);
|
||||
static napi_value Current(napi_env env, napi_callback_info info);
|
||||
static napi_value First(napi_env env, napi_callback_info info);
|
||||
static napi_value Last(napi_env env, napi_callback_info info);
|
||||
static napi_value Previous(napi_env env, napi_callback_info info);
|
||||
static napi_value Next(napi_env env, napi_callback_info info);
|
||||
static napi_value SetText(napi_env env, napi_callback_info info);
|
||||
static napi_value GetText(napi_env env, napi_callback_info info);
|
||||
static napi_value Following(napi_env env, napi_callback_info info);
|
||||
static napi_value IsBoundary(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetIndexUtil(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexUtilConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndexList(napi_env env, napi_callback_info info);
|
||||
static napi_value AddLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndex(napi_env env, napi_callback_info info);
|
||||
bool InitIndexUtilContext(napi_env env, napi_callback_info info, const std::string &localeTag);
|
||||
static napi_value CreateUtilObject(napi_env env);
|
||||
static napi_value CreateCharacterObject(napi_env env);
|
||||
|
||||
static napi_value I18nTimeZoneConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value GetID(napi_env env, napi_callback_info info);
|
||||
static int32_t GetParameter(napi_env env, napi_value *argv, std::string &localeStr, bool &isDST);
|
||||
static napi_value GetTimeZoneDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRawOffset(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value Transform(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateTransliteratorObject(napi_env env);
|
||||
bool InitTransliteratorContext(napi_env env, napi_callback_info info, const std::string &idTag);
|
||||
static napi_value TransliteratorConstructor(napi_env env, napi_callback_info info);
|
||||
static std::string ModifyOrder(std::string &pattern);
|
||||
static void ProcessNormal(char ch, int *order, size_t orderSize, int *lengths, size_t lengsSize);
|
||||
static bool GetStringFromJS(napi_env env, napi_value argv, std::string &jsString);
|
||||
|
||||
static napi_value StaticGetTimeZone(napi_env, napi_value *argv, bool isZoneID);
|
||||
static napi_value CreateTimeZoneObject(napi_env env);
|
||||
|
||||
napi_env env_;
|
||||
napi_ref wrapper_;
|
||||
std::unique_ptr<PhoneNumberFormat> phonenumberfmt_ = nullptr;
|
||||
std::unique_ptr<I18nCalendar> calendar_ = nullptr;
|
||||
std::unique_ptr<icu::Transliterator> transliterator_ = nullptr;
|
||||
std::unique_ptr<I18nBreakIterator> brkiter_ = nullptr;
|
||||
std::unique_ptr<IndexUtil> indexUtil_ = nullptr;
|
||||
std::unique_ptr<I18nTimeZone> timezone_ = nullptr;
|
||||
};
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
/*
|
||||
* Copyright (c) 2021-2022 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.
|
||||
*/
|
||||
#ifndef I18N_ADDON_H
|
||||
#define I18N_ADDON_H
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "napi/native_api.h"
|
||||
#include "i18n_break_iterator.h"
|
||||
#include "i18n_calendar.h"
|
||||
#include "i18n_timezone.h"
|
||||
#include "index_util.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "locale_config.h"
|
||||
#include "measure_data.h"
|
||||
#include "number_format.h"
|
||||
#include "phone_number_format.h"
|
||||
#include "preferred_language.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Global {
|
||||
namespace I18n {
|
||||
void GetOptionMap(napi_env env, napi_value argv, std::map<std::string, std::string> &map);
|
||||
void GetOptionValue(napi_env env, napi_value options, const std::string &optionName,
|
||||
std::string &value);
|
||||
|
||||
class I18nAddon {
|
||||
public:
|
||||
static napi_value Init(napi_env env, napi_value exports);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
I18nAddon();
|
||||
virtual ~I18nAddon();
|
||||
static napi_value GetSystemLanguages(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemCountries(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSuggested(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayCountry(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemRegion(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSystemLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemRegion(napi_env env, napi_callback_info info);
|
||||
static napi_value SetSystemLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRTL(napi_env env, napi_callback_info info);
|
||||
static napi_value InitPhoneNumberFormat(napi_env env, napi_value exports);
|
||||
static napi_value InitI18nCalendar(napi_env env, napi_value exports);
|
||||
static napi_value UnitConvert(napi_env env, napi_callback_info info);
|
||||
static napi_value InitBreakIterator(napi_env env, napi_value exports);
|
||||
static napi_value InitIndexUtil(napi_env env, napi_value exports);
|
||||
static napi_value IsDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSpaceCharAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsWhiteSpaceAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRTLCharacterAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsIdeoGraphicAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsLetterAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsLowerCaseAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value IsUpperCaseAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTypeAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value Is24HourClock(napi_env env, napi_callback_info info);
|
||||
static napi_value Set24HourClock(napi_env env, napi_callback_info info);
|
||||
static napi_value AddPreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value RemovePreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value GetPreferredLanguageList(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFirstPreferredLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value InitI18nTimeZone(napi_env env, napi_value exports);
|
||||
static napi_value GetI18nTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDateOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value InitTransliterator(napi_env env, napi_value exports);
|
||||
static napi_value GetTransliteratorInstance(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value SetUsingLocalDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetUsingLocalDigitAddon(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableTimezoneIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAvailableZoneCityIDs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetCityDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTimezoneFromCity(napi_env env, napi_callback_info info);
|
||||
|
||||
private:
|
||||
static void CreateInitProperties(napi_property_descriptor *properties);
|
||||
static napi_value PhoneNumberFormatConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value IsValidPhoneNumber(napi_env env, napi_callback_info info);
|
||||
static napi_value FormatPhoneNumber(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLocationName(napi_env env, napi_callback_info info);
|
||||
bool InitPhoneNumberFormatContext(napi_env env, napi_callback_info info, const std::string &country,
|
||||
const std::map<std::string, std::string> &options);
|
||||
|
||||
static napi_value CalendarConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value BreakIteratorConstructor(napi_env env, napi_callback_info info);
|
||||
bool InitCalendarContext(napi_env env, napi_callback_info info, const std::string &localeTag, CalendarType type);
|
||||
static napi_value GetCalendar(napi_env env, napi_callback_info info);
|
||||
static napi_value Set(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDate(napi_env env, napi_value value);
|
||||
void SetMilliseconds(napi_env env, napi_value value);
|
||||
void SetField(napi_env env, napi_value value, UCalendarDateFields field);
|
||||
static napi_value SetTime(napi_env env, napi_callback_info info);
|
||||
static std::string GetString(napi_env &env, napi_value &value, int32_t &code);
|
||||
static napi_value SetTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value GetTimeZone(napi_env env, napi_callback_info info);
|
||||
static napi_value SetFirstDayOfWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value GetFirstDayOfWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value SetMinimalDaysInFirstWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value GetMinimalDaysInFirstWeek(napi_env env, napi_callback_info info);
|
||||
static napi_value Get(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value IsWeekend(napi_env env, napi_callback_info info);
|
||||
static CalendarType GetCalendarType(napi_env env, napi_value value);
|
||||
static napi_value GetLineInstance(napi_env env, napi_callback_info info);
|
||||
static napi_value Current(napi_env env, napi_callback_info info);
|
||||
static napi_value First(napi_env env, napi_callback_info info);
|
||||
static napi_value Last(napi_env env, napi_callback_info info);
|
||||
static napi_value Previous(napi_env env, napi_callback_info info);
|
||||
static napi_value Next(napi_env env, napi_callback_info info);
|
||||
static napi_value SetText(napi_env env, napi_callback_info info);
|
||||
static napi_value GetText(napi_env env, napi_callback_info info);
|
||||
static napi_value Following(napi_env env, napi_callback_info info);
|
||||
static napi_value IsBoundary(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetIndexUtil(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexUtilConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndexList(napi_env env, napi_callback_info info);
|
||||
static napi_value AddLocale(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndex(napi_env env, napi_callback_info info);
|
||||
bool InitIndexUtilContext(napi_env env, napi_callback_info info, const std::string &localeTag);
|
||||
static napi_value CreateUtilObject(napi_env env);
|
||||
static napi_value CreateCharacterObject(napi_env env);
|
||||
|
||||
static napi_value I18nTimeZoneConstructor(napi_env env, napi_callback_info info);
|
||||
static napi_value GetID(napi_env env, napi_callback_info info);
|
||||
static int32_t GetParameter(napi_env env, napi_value *argv, std::string &localeStr, bool &isDST);
|
||||
static napi_value GetTimeZoneDisplayName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRawOffset(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value Transform(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateTransliteratorObject(napi_env env);
|
||||
bool InitTransliteratorContext(napi_env env, napi_callback_info info, const std::string &idTag);
|
||||
static napi_value TransliteratorConstructor(napi_env env, napi_callback_info info);
|
||||
static std::string ModifyOrder(std::string &pattern);
|
||||
static void ProcessNormal(char ch, int *order, size_t orderSize, int *lengths, size_t lengsSize);
|
||||
static bool GetStringFromJS(napi_env env, napi_value argv, std::string &jsString);
|
||||
|
||||
static napi_value StaticGetTimeZone(napi_env, napi_value *argv, bool isZoneID);
|
||||
static napi_value CreateTimeZoneObject(napi_env env);
|
||||
|
||||
napi_env env_;
|
||||
napi_ref wrapper_;
|
||||
std::unique_ptr<PhoneNumberFormat> phonenumberfmt_ = nullptr;
|
||||
std::unique_ptr<I18nCalendar> calendar_ = nullptr;
|
||||
std::unique_ptr<icu::Transliterator> transliterator_ = nullptr;
|
||||
std::unique_ptr<I18nBreakIterator> brkiter_ = nullptr;
|
||||
std::unique_ptr<IndexUtil> indexUtil_ = nullptr;
|
||||
std::unique_ptr<I18nTimeZone> timezone_ = nullptr;
|
||||
};
|
||||
} // namespace I18n
|
||||
} // namespace Global
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user