Lines Matching defs:env
55 void I18nAddon::Destructor(napi_env env, void *nativeObject, void *hint)
64 napi_value I18nAddon::InitI18nUtil(napi_env env, napi_value exports)
75 napi_status status = napi_define_class(env, "I18NUtil", NAPI_AUTO_LENGTH, JSUtils::DefaultConstructor, nullptr,
82 status = napi_set_named_property(env, exports, "I18NUtil", constructor);
90 napi_value I18nAddon::Init(napi_env env, napi_value exports)
110 DECLARE_NAPI_PROPERTY("NormalizerMode", I18nNormalizerAddon::CreateI18NNormalizerModeEnum(env, initStatus))
112 initStatus = napi_define_properties(env, exports, sizeof(properties) / sizeof(napi_property_descriptor),
121 void GetOptionMap(napi_env env, napi_value option, std::map<std::string, std::string> &map)
123 if (VariableConvertor::CheckNapiValueType(env, option)) {
125 napi_get_value_string_utf8(env, option, nullptr, 0, &len);
127 napi_status status = napi_get_value_string_utf8(env, option, styleBuf.data(), len + 1, &len);
136 napi_value I18nAddon::UnitConvert(napi_env env, napi_callback_info info)
142 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
147 VariableConvertor::GetOptionValue(env, argv[0], "unit", fromUnit);
149 VariableConvertor::GetOptionValue(env, argv[0], "measureSystem", fromMeasSys);
151 VariableConvertor::GetOptionValue(env, argv[1], "unit", toUnit);
153 VariableConvertor::GetOptionValue(env, argv[1], "measureSystem", toMeasSys);
155 napi_get_value_double(env, argv[2], &number); // 2 is the index of value
158 napi_get_value_string_utf8(env, argv[3], nullptr, 0, &len); // 3 is the index of value
161 status = napi_get_value_string_utf8(env, argv[3], localeBuf.data(), len + 1, &len);
175 GetOptionMap(env, argv[4], map);
180 status = napi_create_string_utf8(env, value.c_str(), NAPI_AUTO_LENGTH, &result);
188 napi_value I18nAddon::GetDateOrder(napi_env env, napi_callback_info info)
194 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
199 napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
201 status = napi_get_value_string_utf8(env, argv[0], languageBuf.data(), len + 1, &len);
209 status = napi_create_string_utf8(env, value.c_str(), NAPI_AUTO_LENGTH, &result);
217 napi_value I18nAddon::GetTimePeriodName(napi_env env, napi_callback_info info)
222 if (GetParamOfGetTimePeriodName(env, info, localeTag, hour) == -1) {
224 napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &result);
231 ErrorUtil::NapiThrow(env, I18N_NOT_VALID, "locale", "a valid locale", true);
238 napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &result);
249 napi_create_string_utf8(env, PseudoLocalizationProcessor(temp).c_str(), NAPI_AUTO_LENGTH, &result);
255 int I18nAddon::GetParamOfGetTimePeriodName(napi_env env, napi_callback_info info, std::string &tag, int32_t &hour)
261 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
266 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "hour", "", true);
271 napi_typeof(env, argv[0], &valueType);
273 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "hour", "number", true);
276 status = napi_get_value_int32(env, argv[0], &hour);
283 napi_typeof(env, argv[1], &valueType);
288 tag = VariableConvertor::GetString(env, argv[1], code);
294 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale", "string", true);
300 LocaleInfo* ProcessJsParamLocale(napi_env env, napi_value argv)
303 std::string localeTag = VariableConvertor::GetString(env, argv, code);
311 ErrorUtil::NapiThrow(env, I18N_NOT_VALID, "locale", "a valid locale", true);
317 bool ProcessJsParamLocaleList(napi_env env, napi_value argv, std::vector<LocaleInfo*> &candidateLocales,
321 if (!VariableConvertor::GetStringArrayFromJsParam(env, argv, "localeList", localeTagList)) {
333 ErrorUtil::NapiThrow(env, I18N_NOT_VALID, "locale of localeList", "a valid locale", true);
354 napi_value I18nAddon::GetBestMatchLocale(napi_env env, napi_callback_info info)
360 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
362 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale or localeList", "", true);
365 LocaleInfo *requestLocale = ProcessJsParamLocale(env, argv[0]);
370 bool isValidParam = ProcessJsParamLocaleList(env, argv[1], candidateLocales, requestLocale);
387 status = napi_create_string_utf8(env, bestMatchLocaleTag.c_str(), NAPI_AUTO_LENGTH, &result);
395 napi_value I18nAddon::GetThreeLetterLanguage(napi_env env, napi_callback_info info)
401 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
406 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale", "", true);
411 napi_typeof(env, argv[0], &valueType);
413 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale", "string", true);
418 std::string languageTag = VariableConvertor::GetString(env, argv[0], code);
427 status = napi_create_string_utf8(env, language.c_str(), NAPI_AUTO_LENGTH, &result);
430 ErrorUtil::NapiThrow(env, I18N_NOT_VALID, "locale", "a valid locale", true);
436 napi_value I18nAddon::GetThreeLetterRegion(napi_env env, napi_callback_info info)
442 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
447 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale", "", true);
452 napi_typeof(env, argv[0], &valueType);
454 ErrorUtil::NapiThrow(env, I18N_NOT_FOUND, "locale", "string", true);
459 std::string regionTag = VariableConvertor::GetString(env, argv[0], code);
468 status = napi_create_string_utf8(env, country.c_str(), NAPI_AUTO_LENGTH, &result);
471 ErrorUtil::NapiThrow(env, I18N_NOT_VALID, "locale", "a valid locale", true);
477 napi_value I18nAddon::InitI18nTransliterator(napi_env env, napi_value exports)
483 napi_status status = napi_define_class(env, "Transliterator", NAPI_AUTO_LENGTH, I18nTransliteratorConstructor,
489 exports = I18nAddon::InitTransliterator(env, exports);
495 status = napi_create_reference(env, constructor, 1, g_transConstructor);
503 napi_value I18nAddon::InitTransliterator(napi_env env, napi_value exports)
510 napi_status status = napi_define_class(env, "I18nTransliterator", NAPI_AUTO_LENGTH, JSUtils::DefaultConstructor,
516 status = napi_set_named_property(env, exports, "Transliterator", constructor);
524 napi_value I18nAddon::I18nTransliteratorConstructor(napi_env env, napi_callback_info info)
530 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
535 napi_typeof(env, argv[0], &valueType);
541 std::string idTag = VariableConvertor::GetString(env, argv[0], code);
548 napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), I18nAddon::Destructor, nullptr, nullptr);
553 if (!obj->InitTransliteratorContext(env, info, idTag)) {
561 bool I18nAddon::InitTransliteratorContext(napi_env env, napi_callback_info info, const std::string &idTag)
573 napi_value I18nAddon::Transform(napi_env env, napi_callback_info info)
579 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
581 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
590 napi_typeof(env, argv[0], &valueType);
596 status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
602 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
612 status = napi_create_string_utf8(env, temp.c_str(), NAPI_AUTO_LENGTH, &value);
620 napi_value I18nAddon::GetAvailableIDs(napi_env env, napi_callback_info info)
626 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
641 napi_create_array(env, &result);
652 napi_create_string_utf8(env, temp, strlen(temp), &val);
653 napi_set_element(env, result, i, val);
660 napi_value I18nAddon::GetTransliteratorInstance(napi_env env, napi_callback_info info)
666 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
668 napi_status status = napi_get_reference_value(env, *g_transConstructor, &constructor);
674 status = napi_new_instance(env, constructor, 1, argv, &result); // 2 arguments
682 napi_value I18nAddon::IsRTL(napi_env env, napi_callback_info info)
688 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
693 napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
695 status = napi_get_value_string_utf8(env, argv[0], localeBuf.data(), len + 1, &len);
702 status = napi_get_boolean(env, isRTL, &result);
710 napi_value I18nAddon::InitPhoneNumberFormat(napi_env env, napi_value exports)
720 status = napi_define_class(env, "PhoneNumberFormat", NAPI_AUTO_LENGTH, PhoneNumberFormatConstructor, nullptr,
727 status = napi_set_named_property(env, exports, "PhoneNumberFormat", constructor);
735 napi_value I18nAddon::PhoneNumberFormatConstructor(napi_env env, napi_callback_info info)
741 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
746 napi_typeof(env, argv[0], &valueType);
752 status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
758 status = napi_get_value_string_utf8(env, argv[0], country.data(), len + 1, &len);
765 VariableConvertor::GetOptionValue(env, argv[1], "type", typeStr);
769 status = napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()),
775 if (!obj->InitPhoneNumberFormatContext(env, info, country.data(), options)) {
782 bool I18nAddon::InitPhoneNumberFormatContext(napi_env env, napi_callback_info info, const std::string &country,
786 napi_status status = napi_get_global(env, &global);
791 env_ = env;
797 napi_value I18nAddon::IsValidPhoneNumber(napi_env env, napi_callback_info info)
803 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
805 napi_typeof(env, argv[0], &valueType);
812 napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
818 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
825 status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
834 status = napi_get_boolean(env, isValid, &result);
843 napi_value I18nAddon::GetLocationName(napi_env env, napi_callback_info info)
849 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
852 std::string number = VariableConvertor::GetString(env, argv[0], code);
856 std::string language = VariableConvertor::GetString(env, argv[1], code);
862 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
870 status = napi_create_string_utf8(env, resStr.c_str(), NAPI_AUTO_LENGTH, &result);
879 napi_value I18nAddon::FormatPhoneNumber(napi_env env, napi_callback_info info)
885 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
887 napi_typeof(env, argv[0], &valueType);
894 napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
900 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
907 status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
916 status = napi_create_string_utf8(env, formattedPhoneNumber.c_str(), NAPI_AUTO_LENGTH, &result);
924 napi_value I18nAddon::InitI18nIndexUtil(napi_env env, napi_value exports)
933 napi_status status = napi_define_class(env, "IndexUtil", NAPI_AUTO_LENGTH, I18nIndexUtilConstructor, nullptr,
939 exports = I18nAddon::InitIndexUtil(env, exports);
940 status = napi_create_reference(env, constructor, 1, &g_indexUtilConstructor);
948 napi_value I18nAddon::InitIndexUtil(napi_env env, napi_value exports)
952 napi_status status = napi_define_class(env, "I18nIndexUtil", NAPI_AUTO_LENGTH, JSUtils::DefaultConstructor,
958 status = napi_set_named_property(env, exports, "IndexUtil", constructor);
966 napi_value I18nAddon::I18nBreakIteratorConstructor(napi_env env, napi_callback_info info)
972 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
977 napi_typeof(env, argv[0], &valueType);
983 std::string localeTag = VariableConvertor::GetString(env, argv[0], code);
990 napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), I18nAddon::Destructor, nullptr, nullptr);
1004 napi_value I18nAddon::InitI18nBreakIterator(napi_env env, napi_value exports)
1018 napi_status status = napi_define_class(env, "BreakIterator", NAPI_AUTO_LENGTH, I18nBreakIteratorConstructor,
1024 exports = I18nAddon::InitBreakIterator(env, exports);
1030 status = napi_create_reference(env, constructor, 1, g_brkConstructor);
1038 napi_value I18nAddon::InitBreakIterator(napi_env env, napi_value exports)
1042 napi_status status = napi_define_class(env, "I18nBreakIterator", NAPI_AUTO_LENGTH, JSUtils::DefaultConstructor,
1048 status = napi_set_named_property(env, exports, "BreakIterator", constructor);
1056 napi_value I18nAddon::GetLineInstance(napi_env env, napi_callback_info info)
1062 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1064 napi_status status = napi_get_reference_value(env, *g_brkConstructor, &constructor);
1073 status = napi_new_instance(env, constructor, 1, argv, &result); // 1 arguments
1081 napi_value I18nAddon::Current(napi_env env, napi_callback_info info)
1087 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1089 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1096 status = napi_create_int32(env, value, &result);
1104 napi_value I18nAddon::First(napi_env env, napi_callback_info info)
1110 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1112 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1119 status = napi_create_int32(env, value, &result);
1127 napi_value I18nAddon::Last(napi_env env, napi_callback_info info)
1133 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1135 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1142 status = napi_create_int32(env, value, &result);
1150 napi_value I18nAddon::Previous(napi_env env, napi_callback_info info)
1156 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1158 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1165 status = napi_create_int32(env, value, &result);
1173 napi_value I18nAddon::Next(napi_env env, napi_callback_info info)
1179 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1181 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1187 if (VariableConvertor::CheckNapiValueType(env, argv[0])) {
1189 napi_typeof(env, argv[0], &valueType);
1194 status = napi_get_value_int32(env, argv[0], &value);
1202 status = napi_create_int32(env, value, &result);
1210 napi_value I18nAddon::SetText(napi_env env, napi_callback_info info)
1216 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1218 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1227 napi_typeof(env, argv[0], &valueType);
1233 status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
1239 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
1248 napi_value I18nAddon::GetText(napi_env env, napi_callback_info info)
1254 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1256 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1264 status = napi_create_string_utf8(env, temp.c_str(), NAPI_AUTO_LENGTH, &value);
1272 napi_value I18nAddon::Following(napi_env env, napi_callback_info info)
1278 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1280 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1289 napi_typeof(env, argv[0], &valueType);
1295 status = napi_get_value_int32(env, argv[0], &value);
1302 status = napi_create_int32(env, value, &result);
1310 napi_value I18nAddon::IsBoundary(napi_env env, napi_callback_info info)
1316 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1318 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1328 napi_typeof(env, argv[0], &valueType);
1333 status = napi_get_value_int32(env, argv[0], &value);
1340 status = napi_get_boolean(env, boundary, &result);
1348 napi_value I18nAddon::I18nIndexUtilConstructor(napi_env env, napi_callback_info info)
1354 napi_status status = napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1361 napi_typeof(env, argv[0], &valueType);
1367 status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
1373 status = napi_get_value_string_utf8(env, argv[0], localeBuf.data(), len + 1, &len);
1383 napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), I18nAddon::Destructor, nullptr, nullptr);
1388 if (!obj->InitIndexUtilContext(env, info, localeTag)) {
1395 bool I18nAddon::InitIndexUtilContext(napi_env env, napi_callback_info info, const std::string &localeTag)
1398 napi_status status = napi_get_global(env, &global);
1403 env_ = env;
1408 napi_value I18nAddon::GetIndexUtil(napi_env env, napi_callback_info info)
1414 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1416 napi_status status = napi_get_reference_value(env, g_indexUtilConstructor, &constructor);
1422 if (!VariableConvertor::CheckNapiValueType(env, argv[0])) {
1423 status = napi_new_instance(env, constructor, 0, argv, &result);
1425 status = napi_new_instance(env, constructor, 1, argv, &result);
1434 napi_value I18nAddon::GetIndexList(napi_env env, napi_callback_info info)
1438 napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data);
1441 napi_status status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1449 status = napi_create_array_with_length(env, indexList.size(), &result);
1456 status = napi_create_string_utf8(env, indexList[i].c_str(), NAPI_AUTO_LENGTH, &element);
1461 status = napi_set_element(env, result, i, element);
1470 napi_value I18nAddon::AddLocale(napi_env env, napi_callback_info info)
1476 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1478 napi_typeof(env, argv[0], &valueType);
1484 napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
1490 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
1496 status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1505 napi_value I18nAddon::GetIndex(napi_env env, napi_callback_info info)
1511 napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
1513 napi_typeof(env, argv[0], &valueType);
1519 napi_status status = napi_get_value_string_utf8(env, argv[0], nullptr, 0, &len);
1525 status = napi_get_value_string_utf8(env, argv[0], buf.data(), len + 1, &len);
1531 status = napi_unwrap(env, thisVar, reinterpret_cast<void **>(&obj));
1538 status = napi_create_string_utf8(env, index.c_str(), NAPI_AUTO_LENGTH, &result);
1546 napi_value I18nAddon::ObjectConstructor(napi_env env, napi_callback_info info)
1550 napi_status status = napi_get_cb_info(env, info, nullptr, nullptr, &thisVar, &data);
1557 napi_wrap(env, thisVar, reinterpret_cast<void *>(obj.get()), I18nAddon::Destructor, nullptr, nullptr);
1566 napi_value I18nAddon::InitUtil(napi_env env, napi_value exports)
1574 status = napi_define_class(env, "Util", NAPI_AUTO_LENGTH, ObjectConstructor, nullptr,
1581 status = napi_set_named_property(env, exports, "Util", constructor);
1589 napi_value Init(napi_env env, napi_value exports)
1591 napi_value val = I18nAddon::Init(env, exports);
1592 val = I18nAddon::InitPhoneNumberFormat(env, val);
1593 val = I18nAddon::InitI18nBreakIterator(env, val);
1594 val = I18nCalendarAddon::InitI18nCalendar(env, val);
1595 val = I18nAddon::InitI18nIndexUtil(env, val);
1596 val = I18nAddon::InitI18nUtil(env, val);
1597 val = I18nTimeZoneAddon::InitI18nTimeZone(env, val);
1598 val = I18nAddon::InitI18nTransliterator(env, val);
1599 val = I18nUnicodeAddon::InitCharacter(env, val);
1600 val = I18nUnicodeAddon::InitI18nUnicode(env, val);
1601 val = I18nAddon::InitUtil(env, val);
1602 val = I18nNormalizerAddon::InitI18nNormalizer(env, val);
1603 val = SystemLocaleManagerAddon::InitSystemLocaleManager(env, val);
1604 val = I18nSystemAddon::InitI18nSystem(env, val);
1605 val = HolidayManagerAddon::InitHolidayManager(env, val);
1606 val = EntityRecognizerAddon::InitEntityRecognizer(env, val);