case 11:
COPY_STR(str, "I18N_UNUMBER_CURRENCY_PLURAL", strlen("I18N_UNUMBER_CURRENCY_PLURAL"));
break;
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
case 12:
COPY_STR(str, "I18N_UNUMBER_CURRENCY_ACCOUNTING", strlen("I18N_UNUMBER_CURRENCY_ACCOUNTING"));
break;
return 0;
}
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
int32_t _ustring_append_n(i18n_uchar *dest, int32_t dest_length, const i18n_uchar *src, int32_t src_length)
{
for (int32_t i = 0; i < src_length; ++i) {
}
#endif
+#if (__TIZEN_VER >= 5)
+static int __test_plural_rules(char *input_number)
+{
+
+ printf(" - To show plural rules\n");
+ printf(" - Rule text : one: n is 1; few: n in 2..4\n");
+ printf(" - Input number : %s\n", input_number ? input_number : "3");
+
+ printf("****************************************\n");
+
+ i18n_plural_rules_h rules = NULL;
+
+ const char *rule_text = "one: n is 1; few: n in 2..4";
+ PRINT_DEBUG_LOG("%s \n", rule_text);
+
+ /* Creates a plural rules object from a description. */
+ int error_code = i18n_plural_rules_create_rules_from_descr(rule_text, &rules);
+
+ /* Create an enumeration of the keywords for the given locale. */
+ i18n_uenumeration_h keywords = NULL;
+ error_code = i18n_plural_rules_get_keywords(rules, &keywords);
+ CHECK_ERROR("i18n_plural_rules_get_keywords", error_code);
+
+ /* Get the number of the keywords that the enumeration contains. */
+ int32_t count = i18n_uenumeration_count(keywords);
+ printf("Number of keywords: %d\n", count);
+
+ /* Get the first keyword from the enumeration. */
+ int len;
+ const char *keyword = i18n_uenumeration_next(keywords, &len);
+ CHECK_ERROR("i18n_uenumeration_next", get_last_result());
+
+ /* Iterate over all of the keywords found in the enumeration. */
+ printf("Display list of keywords: ");
+ while (keyword != NULL) {
+ /* Display the currently processed keyword. */
+ printf("%s ", keyword);
+
+ /* Get the next keyword from the enumeration. */
+ keyword = i18n_uenumeration_next(keywords, &len);
+ CHECK_ERROR("i18n_uenumeration_next", get_last_result())
+ }
+ printf("\n");
+
+ /* Release the keywords enumeration as it is not needed anymore. */
+ error_code = i18n_uenumeration_destroy(keywords);
+ if (error_code != I18N_ERROR_NONE) {
+ CHECK_ERROR("i18n_uenumeration_destroy", error_code);
+ }
+
+ /* Create unumber format, to get number from user input. */
+ i18n_unumber_format_h unumber;
+ error_code = i18n_unumber_create(I18N_UNUMBER_DECIMAL, NULL, -1, default_locale, NULL, &unumber);
+ CHECK_ERROR("i18n_unumber_create", error_code);
+
+ if (!input_number)
+ input_number = (char *)"3";
+ PRINT_DEBUG_LOG("Input number : %s\n", input_number);
+
+ i18n_uchar i18nchar_input[BUF_SIZE] = { 0 };
+ i18n_ustring_copy_ua(i18nchar_input, input_number);
+
+ /* Parse string to double. */
+ double input = i18n_unumber_parse_double(unumber, i18nchar_input, BUF_SIZE, NULL);
+
+ /* Get rule from user defined number and print it to user. */
+ i18n_uchar buffer[BUF_SIZE] = { 0 };
+ int output_length = -1;
+ error_code = i18n_plural_rules_select_double(rules, input, BUF_SIZE, buffer, &output_length);
+ CHECK_ERROR("i18n_plural_rules_select_double", error_code);
+
+ char output_buffer[BUF_SIZE] = { 0 };
+ i18n_ustring_copy_au_n(output_buffer, buffer, BUF_SIZE);
+ printf("Matched rule: %s \n", output_buffer);
+
+ /* Release the rules as it is not needed anymore. */
+ error_code = i18n_plural_rules_destroy(rules);
+ if (error_code != I18N_ERROR_NONE) {
+ CHECK_ERROR("i18n_plural_rules_destroy", error_code);
+ }
+
+ return 0;
+}
+#endif
+
void allTest()
{
int ret = 0, i = 0;
__show_ubidi(input);
}
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
void testNumberConvert(char *input)
{
int ret = 0;
}
#endif
+#if (__TIZEN_VER >= 5)
+void testPluralRules(char *input)
+{
+ printf("\n== Test Plural Rules");
+ printf("\n****************************************\n");
+ __test_plural_rules(input);
+}
+#endif
+
void showDatentimeFormat(char *locale)
{
int ret = 0, i = 0;
showUbidi(arguments.testTextArg);
}
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
if (arguments.testNumberConvert) {
testNumberConvert(arguments.testNumberConvertArg);
}
showMeasureUnit(arguments.testInputNumArg);
}
#endif
+#if (__TIZEN_VER >= 5)
+ if (arguments.testPluralRules) {
+ testPluralRules(arguments.testPluralRulesArg);
+ }
+#endif
return 0;
}
{"set-locale", 'l', "locale", 0, "Set specific locale", 0 },
{"print-ASCII", 'p', 0, 0, "Print results as the ASCIIDoc Format", 0 },
{"show-ubidi", 'b', 0, OPTION_ARG_OPTIONAL, "Show examples of the Unicode Bidirectional Algorithm", 0 },
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
{"test-number-converting", 'c', "Convert", OPTION_ARG_OPTIONAL, "Number converting test", 0 },
{"show-measure-unit", 'm', "Number", OPTION_ARG_OPTIONAL, "Show measure unit", 0 },
#endif
+#if (__TIZEN_VER >= 5)
+ {"test-plural-rules", 'r', "input", OPTION_ARG_OPTIONAL, "Show Plural Rules", 0},
+#endif
{ 0 }
};
int testStringIter;
int printASCII;
int showUbidi;
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
int testNumberConvert;
int showMeasureUnit;
#endif
+#if (__TIZEN_VER >= 5)
+ int testPluralRules;
+#endif
char *arg1; /* arg1 */
char **strings; /* [string…] */
char *testStringIterArg;
char *setLocale;
char *testTextArg;
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
char *testNumberConvertArg;
char *testInputNumArg;
#endif
+#if (__TIZEN_VER >= 5)
+ char *testPluralRulesArg;
+#endif
char *timezoneId;
};
}
break;
-#if (__TIZEN_VER > 4)
+#if (__TIZEN_VER >= 4)
case 'm':
arguments->arg_flag = 16;
arguments->showMeasureUnit = 1;
break;
#endif
+#if (__TIZEN_VER >= 5)
+ case 'r':
+ arguments->arg_flag = 17;
+ arguments->testPluralRules = 1;
+
+ nextArg = state->argv[state->next];
+ if (nextArg && *nextArg != '-') {
+ arguments->testPluralRulesArg = nextArg;
+ state->next++;
+ }
+ break;
+#endif
case 'T':
arguments->arg_flag = 15;