mirror of
https://gitee.com/openharmony/global_i18n
synced 2025-02-18 15:10:53 +00:00
update intl
Signed-off-by: meaty-bag-and-wangwang-meat <zouzhexi@huawei.com>
This commit is contained in:
parent
15302dcb12
commit
d9feb14970
@ -134,10 +134,16 @@ void GetOptionValue(napi_env env, napi_value options, const std::string &optionN
|
||||
std::map<std::string, std::string> &map)
|
||||
{
|
||||
napi_value optionValue = nullptr;
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, options, &type);
|
||||
if (status != napi_ok && type != napi_object) {
|
||||
HiLog::Error(LABEL, "Set option failed, option is not an object");
|
||||
return;
|
||||
}
|
||||
bool hasProperty = false;
|
||||
napi_has_named_property(env, options, optionName.c_str(), &hasProperty);
|
||||
if (hasProperty) {
|
||||
napi_status status = napi_get_named_property(env, options, optionName.c_str(), &optionValue);
|
||||
napi_status propStatus = napi_has_named_property(env, options, optionName.c_str(), &hasProperty);
|
||||
if (propStatus != napi_ok && hasProperty) {
|
||||
status = napi_get_named_property(env, options, optionName.c_str(), &optionValue);
|
||||
if (status == napi_ok) {
|
||||
size_t len;
|
||||
napi_get_value_string_utf8(env, optionValue, nullptr, 0, &len);
|
||||
@ -152,10 +158,16 @@ void GetBoolOptionValue(napi_env env, napi_value options, const std::string &opt
|
||||
std::map<std::string, std::string> &map)
|
||||
{
|
||||
napi_value optionValue = nullptr;
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, options, &type);
|
||||
if (status != napi_ok && type != napi_object) {
|
||||
HiLog::Error(LABEL, "Set option failed, option is not an object");
|
||||
return;
|
||||
}
|
||||
bool hasProperty = false;
|
||||
napi_has_named_property(env, options, optionName.c_str(), &hasProperty);
|
||||
if (hasProperty) {
|
||||
napi_status status = napi_get_named_property(env, options, optionName.c_str(), &optionValue);
|
||||
napi_status propStatus = napi_has_named_property(env, options, optionName.c_str(), &hasProperty);
|
||||
if (propStatus != napi_ok && hasProperty) {
|
||||
status = napi_get_named_property(env, options, optionName.c_str(), &optionValue);
|
||||
if (status == napi_ok) {
|
||||
bool boolValue = false;
|
||||
napi_get_value_bool(env, optionValue, &boolValue);
|
||||
@ -190,7 +202,11 @@ void GetDateOptionValues(napi_env env, napi_value options, std::map<std::string,
|
||||
napi_value IntlAddon::LocaleConstructor(napi_env env, napi_callback_info info)
|
||||
{
|
||||
// Need to get one parameter of a locale in string format to create Locale object.
|
||||
GET_PARAMS(env, info, 2);
|
||||
size_t argc = 2;
|
||||
napi_value argv[2] = { 0 };
|
||||
napi_value thisVar = nullptr;
|
||||
void *data = nullptr;
|
||||
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
if (valueType != napi_valuetype::napi_string) {
|
||||
@ -198,7 +214,7 @@ napi_value IntlAddon::LocaleConstructor(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
size_t len;
|
||||
napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
|
||||
status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Get locale tag length failed");
|
||||
return nullptr;
|
||||
@ -277,7 +293,11 @@ void GetLocaleTags(napi_env env, napi_value rawLocaleTag, std::vector<std::strin
|
||||
napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info info)
|
||||
{
|
||||
// Need to get one parameter of a locale in string format to create DateTimeFormat object.
|
||||
GET_PARAMS(env, info, 2);
|
||||
size_t argc = 2;
|
||||
napi_value argv[2] = { 0 };
|
||||
napi_value thisVar = nullptr;
|
||||
void *data = nullptr;
|
||||
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
std::vector<std::string> localeTags;
|
||||
@ -308,7 +328,7 @@ napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_status status =
|
||||
status =
|
||||
napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), IntlAddon::Destructor, nullptr, &obj->wrapper_);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Wrap IntlAddon failed");
|
||||
@ -407,7 +427,11 @@ napi_value IntlAddon::FormatDateTimeRange(napi_env env, napi_callback_info info)
|
||||
napi_value IntlAddon::NumberFormatConstructor(napi_env env, napi_callback_info info)
|
||||
{
|
||||
// Need to get one parameter of a locale in string format to create DateTimeFormat object.
|
||||
GET_PARAMS(env, info, 2);
|
||||
size_t argc = 2;
|
||||
napi_value argv[2] = { 0 };
|
||||
napi_value thisVar = nullptr;
|
||||
void *data = nullptr;
|
||||
napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
|
||||
napi_valuetype valueType = napi_valuetype::napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
std::vector<std::string> localeTags;
|
||||
@ -454,7 +478,7 @@ napi_value IntlAddon::NumberFormatConstructor(napi_env env, napi_callback_info i
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_status status =
|
||||
status =
|
||||
napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), IntlAddon::Destructor, nullptr, &obj->wrapper_);
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Wrap IntlAddon failed");
|
||||
|
Loading…
x
Reference in New Issue
Block a user