* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
- * <td>#i18n_timezone_get_display_name_with_locale</td>
- * <td>getDisplayName</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
* <td>#i18n_timezone_get_display_name_with_type</td>
* <td>getDisplayName</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
- * <td>#i18n_timezone_get_display_name_with_type_locale</td>
- * <td>getDisplayName</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
* <td>#i18n_timezone_use_daylight_time</td>
* <td>useDaylightTime</td>
* </tr>
* <td>detectHostTimeZone</td>
* </tr>
* <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
+ * <td>#i18n_timezone_get_display_name_with_locale_id</td>
+ * <td>getDisplayName</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_TIMEZONE_MODULE</td>
+ * <td>#i18n_timezone_get_display_name_with_type_locale_id</td>
+ * <td>getDisplayName</td>
+ * </tr>
+ * <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_UENUMERATION_MODULE</td>
* <td>#i18n_uenumeration_destroy</td>
* <td>uenum_close</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
- * <td>#i18n_alpha_idx_create</td>
- * <td>AlphabeticIndex</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
* <td>#i18n_alpha_idx_destroy</td>
* <td>~AlphabeticIndex</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
- * <td>#i18n_alpha_idx_add_labels</td>
- * <td>addLabels</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
* <td>#i18n_alpha_idx_add_record</td>
* <td>addRecord</td>
* </tr>
* <td>resetRecordIterator</td>
* </tr>
* <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_create_from_locale_id</td>
+ * <td>AlphabeticIndex</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_ALPHA_IDX_MODULE</td>
+ * <td>#i18n_alpha_idx_add_labels_with_locale_id</td>
+ * <td>addLabels</td>
+ * </tr>
+ * <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_FORMATTABLE_MODULE</td>
* <td>#i18n_formattable_create_default</td>
* <td>Formattable()</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_FORMAT_MODULE</td>
- * <td>#i18n_format_get_locale</td>
+ * <td>#i18n_format_get_locale_id</td>
* <td>getLocale</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
- * <td>#i18n_measure_format_create</td>
- * <td>MeasureFormat</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
* <td>#i18n_measure_format_destroy</td>
* <td>~MeasureFormat</td>
* </tr>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
- * <td>#i18n_measure_format_create_currency_format_from_locale</td>
- * <td>createCurrencyFormat</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
* <td>#i18n_measure_format_create_currency_format</td>
* <td>createCurrencyFormat</td>
* </tr>
* <td>getUnitDisplayName</td>
* </tr>
* <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
+ * <td>#i18n_measure_format_create_from_locale_id</td>
+ * <td>MeasureFormat</td>
+ * </tr>
+ * <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_MEASURE_FORMAT_MODULE</td>
+ * <td>#i18n_measure_format_create_currency_format_from_locale_id</td>
+ * <td>createCurrencyFormat</td>
+ * </tr>
+ * <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_FIELD_POSITION_MODULE</td>
* <td>#i18n_field_position_create</td>
* <td>FieldPosition</td>
* </tr>
* <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_PLURAL_RULES_MODULE</td>
- * <td>#i18n_plural_rules_for_locale</td>
- * <td>forLocale</td>
- * </tr>
- * <tr>
- * <td>@ref CAPI_BASE_UTILS_I18N_PLURAL_RULES_MODULE</td>
* <td>#i18n_plural_rules_select_int32</td>
* <td>select</td>
* </tr>
* <td>getKeywordOther</td>
* </tr>
* <tr>
+ * <td>@ref CAPI_BASE_UTILS_I18N_PLURAL_RULES_MODULE</td>
+ * <td>#i18n_plural_rules_for_locale_id</td>
+ * <td>forLocale</td>
+ * </tr>
+ * <tr>
* <td>@ref CAPI_BASE_UTILS_I18N_PLURAL_FORMAT_MODULE</td>
* <td>#i18n_plural_format_create</td>
* <td>PluralFormat</td>
*/
/**
+ * @deprecated Deprecated since 5.0. Use i18n_alpha_idx_create_from_locale_id() instead.
* @brief Creates an alphabetic index object for the specified locale.
* @details If the locale's data does not include index characters,
* a set of them will be synthesized based on the locale's
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
int i18n_alpha_idx_create(const char *language, const char *country,
- i18n_alpha_idx_h *index);
+ i18n_alpha_idx_h *index) TIZEN_DEPRECATED_API;
/**
* @brief Destroys the alphabetic index object.
int i18n_alpha_idx_destroy(i18n_alpha_idx_h index);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_alpha_idx_add_labels_with_locale_id() instead.
* @brief Adds the index characters from a specified locale to the index.
* @details The labels are added to those that are already in the index;
* they do not replace the existing index characters. The collation
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
*/
int i18n_alpha_idx_add_labels(i18n_alpha_idx_h index, const char *language,
- const char *country);
+ const char *country) TIZEN_DEPRECATED_API;
/**
* @brief Adds the record to the alphabetic index.
*/
int i18n_alpha_idx_reset_record_iter(i18n_alpha_idx_h index);
+
+/**
+ * @brief Creates an alphabetic index object for the specified locale.
+ * @details If the locale's data does not include index characters,
+ * a set of them will be synthesized based on the locale's
+ * exemplar characters. The locale determines the sorting order
+ * for both the index characters and the user item names appearing
+ * under each Index character.
+ * @since_tizen 5.0
+ * @remarks The created object should be released by the caller with the
+ * #i18n_alpha_idx_destroy() function.
+ *
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[out] index The created alphabetic index object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_alpha_idx_create_from_locale_id(const char *locale_id, i18n_alpha_idx_h *index);
+
+/**
+ * @brief Adds the index characters from a specified locale to the index.
+ * @details The labels are added to those that are already in the index;
+ * they do not replace the existing index characters. The collation
+ * order for this index is not changed; it remains that of the locale
+ * that was originally specified when creating this Index.
+ * @since_tizen 5.0
+ *
+ * @param[in] index Label will be added to this alphabetic index
+ * @param[in] locale_id The locale string containing language and country code
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_alpha_idx_add_labels_with_locale_id(i18n_alpha_idx_h index, const char *locale_id);
+
/**
* @}
*/
int i18n_format_parse_object_with_parse_position(i18n_format_h format, const char *source, i18n_parse_position_h parse_position, i18n_formattable_h *result);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_format_get_locale_id() instead.
* @brief Gets the locale for the given format object.
* @details You can choose between valid and actual locale.
* @since_tizen 2.3.2 and 3.0
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
int i18n_format_get_locale(i18n_format_h format,
- i18n_ulocale_data_locale_type_e type, char **language, char **country);
+ i18n_ulocale_data_locale_type_e type,
+ char **language, char **country) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Gets the locale for the given format object.
+ * @details You can choose between valid and actual locale.
+ * @since_tizen 5.0
+ * @remarks @a locale_id should be released by the caller with the free() function.
+ *
+ * @param[in] format The format object
+ * @param[in] type The type of the locale we're looking for (valid or actual)
+ * @param[out] locale_id The locale indentifier
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_format_get_locale_id(i18n_format_h format,
+ i18n_ulocale_data_locale_type_e type, char **locale_id);
+
/**
* @}
*/
/**
+ * @deprecated Deprecated since 5.0. Use i18n_measure_format_create_from_locale_id() instead.
* @brief Creates the measure format object using given locale.
* @since_tizen 2.3.2 and 3.0
* @remarks The created object should be released by the caller with the
int i18n_measure_format_create(const char *language,
const char *country,
i18n_umeasure_format_width_e width,
- i18n_measure_format_h *measure_format);
+ i18n_measure_format_h *measure_format) TIZEN_DEPRECATED_API;
/**
- * @brief Destroys the measure format object
+ * @brief Destroys the measure format object.
* @since_tizen 2.3.2 and 3.0
*
* @param[in] measure_format The measure format object to destroy
i18n_formattable_h *result);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_measure_format_create_currency_format_from_locale_id() instead.
* @brief Gets a formatter for currency amount objects in the given locale.
* @since_tizen 2.3.2 and 3.0
* @remarks The created object should be released by the caller with the
*/
int i18n_measure_format_create_currency_format_from_locale(const char *language,
const char *country,
- i18n_measure_format_h *measure_format);
+ i18n_measure_format_h *measure_format) TIZEN_DEPRECATED_API;
/**
* @brief Gets a formatter for currency amount objects in the default locale.
* inserted to the @a buffer and #I18N_ERROR_BUFFER_OVERFLOW
* is returned.
* @param[out] buffer The buffer to which the formatted string will be inserted.
- * Can be @c NULL if <code>@a output_buffer_size <= 0</code>.
+ * Can be @c NULL if <code>@a buffer_size <= 0</code>.
* @param[out] output_length The length of the output string
*
* @return @c 0 on success, otherwise a negative error value
int32_t *output_length);
/**
+ * @brief Creates the measure format object using given locale.
+ * @since_tizen 5.0
+ * @remarks The created object should be released by the caller with the
+ * i18n_measure_format_destroy() function.
+ *
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[in] width The format width
+ * @param[out] measure_format The created measure format object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_measure_format_create_from_locale_id(const char *locale_id,
+ i18n_umeasure_format_width_e width,
+ i18n_measure_format_h *measure_format);
+
+/**
+ * @brief Gets a formatter for currency amount objects in the given locale.
+ * @since_tizen 5.0
+ * @remarks The created object should be released by the caller with the
+ * i18n_measure_format_destroy() function.
+ *
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[out] measure_format The measure format object
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_measure_format_create_currency_format_from_locale_id(const char *locale_id,
+ i18n_measure_format_h *measure_format);
+
+/**
* @}
*/
* @remarks The created object should be released by the caller with the
* i18n_plural_format_destroy() function.
*
- * @param[in] language The language of the locale
- * @param[in] country The country of the locale
+ * @param[in] locale The locale string containing language and country code
* @param[out] plural_format The created plural format object
*
* @return @c 0 on success, otherwise a negative error value
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
-int i18n_plural_format_create_from_locale(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale(const char *locale,
i18n_plural_format_h *plural_format);
/**
* @remarks The created object should be released by the caller with the
* i18n_plural_format_destroy() function.
*
- * @param[in] language The language of the locale
- * @param[in] country The country of the locale
+ * @param[in] locale The locale string containing language and country code
* @param[in] type The plural type
* @param[in] pattern The pattern for this plural format object
* @param[out] plural_format The created plural format object
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
-int i18n_plural_format_create_from_locale_type_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_type_pattern(const char *locale,
i18n_uplural_type_e type,
const char *pattern,
i18n_plural_format_h *plural_format);
* @remarks The created object should be released by the caller with the
* i18n_plural_format_destroy() function.
*
- * @param[in] language The language of the locale
- * @param[in] country The country of the locale
+ * @param[in] locale The locale string containing language and country code
* @param[in] type The plural type
* @param[out] plural_format The created plural format object
*
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
-int i18n_plural_format_create_from_locale_type(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_type(const char *locale,
i18n_uplural_type_e type,
i18n_plural_format_h *plural_format);
* @remarks The created object should be released by the caller with the
* i18n_plural_format_destroy() function.
*
- * @param[in] language The language of the locale
- * @param[in] country The country of the locale
+ * @param[in] locale The locale string containing language and country code
* @param[in] pattern The pattern for this plural format object
* @param[out] plural_format The created plural format object
*
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
-int i18n_plural_format_create_from_locale_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_pattern(const char *locale,
const char *pattern,
i18n_plural_format_h *plural_format);
* @remarks The created object should be released by the caller with the
* i18n_plural_format_destroy() function.
*
- * @param[in] language The language of the locale
- * @param[in] country The country of the locale
+ * @param[in] locale The locale string containing language and country code
* @param[in] plural_rules Plural rules which defines the behavior of the plural format object
* @param[in] pattern The pattern for this plural format object
* @param[out] plural_format The created plural format object
* @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
* @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
*/
-int i18n_plural_format_create_from_locale_rules_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_rules_pattern(const char *locale,
i18n_plural_rules_h plural_rules,
const char *pattern,
i18n_plural_format_h *plural_format);
int i18n_plural_rules_create_rules_from_descr(const char *description, i18n_plural_rules_h *plural_rules);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_plural_rules_for_locale_id() instead.
* @brief Provides access to the predefined plural rules object for a given locale and the plural type.
* @details If there's no predefined rules for this locale, the rules for the closest parent
* in the locale hierarchy that has one will be returned.
int i18n_plural_rules_for_locale(const char *language,
const char *country,
i18n_uplural_type_e type,
- i18n_plural_rules_h *plural_rules);
+ i18n_plural_rules_h *plural_rules) TIZEN_DEPRECATED_API;
/**
* @brief Returns the keyword of the first rule that applies to the given number.
i18n_uchar *output_buffer,
int32_t *output_length);
+/**
+ * @brief Provides access to the predefined plural rules object for a given locale and the plural type.
+ * @details If there's no predefined rules for this locale, the rules for the closest parent
+ * in the locale hierarchy that has one will be returned.
+ * The final fallback always returns the default 'other' rules.
+ * @since_tizen 5.0
+ * @remarks The created object should be released by the caller with the
+ * i18n_plural_rules_destroy() function.
+ *
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[in] type The plural type (e.g., cardinal or ordinal)
+ * @param[out] plural_rules The pointer to the plural rules object for given locale
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ * @retval #I18N_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int i18n_plural_rules_for_locale_id(const char *locale_id,
+ i18n_uplural_type_e type,
+ i18n_plural_rules_h *plural_rules);
+
/**
int i18n_timezone_get_display_name(i18n_timezone_h timezone, char **display_name);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_timezone_get_display_name_with_locale_id() instead.
* @brief Returns a name of this time zone suitable for presentation to the user in the default locale.
* @details This method returns the long name, not including daylight savings.
* If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm.
int i18n_timezone_get_display_name_with_type(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, char **display_name);
/**
+ * @deprecated Deprecated since 5.0. Use i18n_timezone_get_display_name_with_type_locale_id() instead.
* @brief Returns a name of this time zone suitable for presentation to the user in the default locale.
* @details If the display name is not available for the locale,
* then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm.
*/
int i18n_timezone_detect_host_timezone(i18n_timezone_h *timezone);
+/**
+ * @brief Returns a name of this time zone suitable for presentation to the user in the default locale.
+ * @details This method returns the long name, not including daylight savings.
+ * If the display name is not available for the locale, then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm.
+ * @since_tizen 5.0
+ * @remarks @a display_name is allocated on heap and should be released by the caller with the free() function.
+ *
+ * @param[in] timezone The i18n_timezone_h to get a display name
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[out] display_name The human-readable name of this time zone in the default locale
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_timezone_get_display_name_with_locale_id(i18n_timezone_h timezone, const char *locale_id , char **display_name);
+
+/**
+ * @brief Returns a name of this time zone suitable for presentation to the user in the default locale.
+ * @details If the display name is not available for the locale,
+ * then this method returns a string in the localized GMT offset format such as GMT[+-]HH:mm.
+ * @since_tizen 5.0
+ * @remarks @a display_name is allocated on heap and should be released by the caller with the free() function.
+ *
+ * @param[in] timezone The i18n_timezone_h to get a display name
+ * @param[in] daylight If true, display_name is filled with the daylight savings name
+ * @param[in] style The style displayed on
+ * @param[in] locale_id The locale string containing language and country code
+ * @param[out] display_name The human-readable name of this time zone in the default locale
+ *
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #I18N_ERROR_NONE Successful
+ * @retval #I18N_ERROR_INVALID_PARAMETER Invalid function parameter
+ */
+int i18n_timezone_get_display_name_with_type_locale_id(i18n_timezone_h timezone, i18n_ubool daylight, i18n_timezone_display_type_e style, const char *locale_id, char **display_name);
+
#ifdef __cplusplus
}
#endif
return I18N_ERROR_NONE;
}
+
+int i18n_alpha_idx_create_from_locale_id(const char *locale_id, i18n_alpha_idx_h *index)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Locale locale(locale_id, 0, 0, 0);
+ UErrorCode status = U_ZERO_ERROR;
+
+ *index = new AlphabeticIndex(locale, status);
+ retv_if(*index == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_alpha_idx_add_labels_with_locale_id(i18n_alpha_idx_h index,
+ const char *locale_id)
+{
+ retv_if(index == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Locale locale(locale_id, 0, 0, 0);
+ UErrorCode status = U_ZERO_ERROR;
+
+ ((AlphabeticIndex *) index)->addLabels(locale, status);
+
+ return _i18n_error_mapping(status);
+}
return _i18n_error_mapping(status);
}
+
+int i18n_format_get_locale_id(i18n_format_h format, i18n_ulocale_data_locale_type_e type,
+ char **locale_id)
+{
+ retv_if(format == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(type < I18N_ULOCALE_DATA_LOCALE_TYPE_ACTUAL_LOCALE || type > I18N_ULOCALE_DATA_LOCALE_TYPE_VALID_LOCALE, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(locale_id == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+ ULocDataLocaleType icu_type = (ULocDataLocaleType) type;
+
+ Locale locale = ((Format *) format)->getLocale(icu_type, status);
+
+ *locale_id = strdup(locale.getName());
+
+ return _i18n_error_mapping(status);
+}
return _i18n_error_mapping(status);
}
+int i18n_measure_format_create_from_locale_id(const char *locale_id,
+ i18n_umeasure_format_width_e width,
+ i18n_measure_format_h *measure_format)
+{
+ retv_if(measure_format == NULL, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(width < I18N_UMEASFMT_WIDTH_WIDE, I18N_ERROR_INVALID_PARAMETER);
+ retv_if(width >= I18N_UMEASFMT_WIDTH_COUNT, I18N_ERROR_INVALID_PARAMETER);
+ UErrorCode status = U_ZERO_ERROR;
+ Locale locale(locale_id, 0, 0, 0);
+ UMeasureFormatWidth icu_width = (UMeasureFormatWidth) width;
+
+ *measure_format = new MeasureFormat(locale, icu_width, status);
+ retv_if(*measure_format == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return _i18n_error_mapping(status);
+}
+
+int i18n_measure_format_create_currency_format_from_locale_id(const char *locale_id,
+ i18n_measure_format_h *measure_format)
+{
+ retv_if(measure_format == NULL, I18N_ERROR_INVALID_PARAMETER);
+ UErrorCode status = U_ZERO_ERROR;
+ Locale locale(locale_id, 0, 0, 0);
+
+ *measure_format = MeasureFormat::createCurrencyFormat(locale, status);
+ retv_if(*measure_format == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ return _i18n_error_mapping(status);
+}
}
-int i18n_plural_format_create_from_locale(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale(const char *locale,
i18n_plural_format_h *plural_format)
{
retv_if(plural_format == NULL, I18N_ERROR_INVALID_PARAMETER);
UErrorCode status = U_ZERO_ERROR;
- *plural_format = new PluralFormat(Locale(language, country, 0, 0), status);
+ *plural_format = new PluralFormat(Locale(locale, 0, 0, 0), status);
retv_if(*plural_format == NULL, I18N_ERROR_OUT_OF_MEMORY);
return _i18n_error_mapping(status);
return _i18n_error_mapping(status);
}
-int i18n_plural_format_create_from_locale_type_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_type_pattern(const char *locale,
i18n_uplural_type_e type,
const char *pattern,
i18n_plural_format_h *plural_format)
UErrorCode status = U_ZERO_ERROR;
UnicodeString unicode_pattern(pattern);
- *plural_format = new PluralFormat(Locale(language, country, 0, 0),
+ *plural_format = new PluralFormat(Locale(locale, 0, 0, 0),
(UPluralType)type,
unicode_pattern,
status);
return _i18n_error_mapping(status);
}
-int i18n_plural_format_create_from_locale_type(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_type(const char *locale,
i18n_uplural_type_e type,
i18n_plural_format_h *plural_format)
{
retv_if(type < 0 || type > I18N_UPLURAL_TYPE_ORDINAL, I18N_ERROR_INVALID_PARAMETER);
UErrorCode status = U_ZERO_ERROR;
- *plural_format = new PluralFormat(Locale(language, country, 0, 0), (UPluralType)type, status);
+ *plural_format = new PluralFormat(Locale(locale, 0, 0, 0), (UPluralType)type, status);
retv_if(*plural_format == NULL, I18N_ERROR_OUT_OF_MEMORY);
return _i18n_error_mapping(status);
}
-int i18n_plural_format_create_from_locale_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_pattern(const char *locale,
const char *pattern,
i18n_plural_format_h *plural_format)
{
UErrorCode status = U_ZERO_ERROR;
UnicodeString unicode_pattern(pattern);
- *plural_format = new PluralFormat(Locale(language, country, 0, 0), unicode_pattern, status);
+ *plural_format = new PluralFormat(Locale(locale, 0, 0, 0), unicode_pattern, status);
retv_if(*plural_format == NULL, I18N_ERROR_OUT_OF_MEMORY);
return _i18n_error_mapping(status);
}
-int i18n_plural_format_create_from_locale_rules_pattern(const char *language,
- const char *country,
+int i18n_plural_format_create_from_locale_rules_pattern(const char *locale,
i18n_plural_rules_h plural_rules,
const char *pattern,
i18n_plural_format_h *plural_format)
UErrorCode status = U_ZERO_ERROR;
UnicodeString unicode_pattern(pattern);
- *plural_format = new PluralFormat(Locale(language, country, 0, 0),
+ *plural_format = new PluralFormat(Locale(locale, 0, 0, 0),
*((PluralRules *)plural_rules),
unicode_pattern,
status);
return I18N_ERROR_NONE;
}
+
+int i18n_plural_rules_for_locale_id(const char *locale_id,
+ i18n_uplural_type_e type,
+ i18n_plural_rules_h *plural_rules)
+{
+ retv_if(plural_rules == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ UErrorCode status = U_ZERO_ERROR;
+ *plural_rules = PluralRules::forLocale(Locale(locale_id, 0, 0, 0), (UPluralType)type, status);
+
+ return _i18n_error_mapping(status);
+}
return I18N_ERROR_NONE;
}
+
+int i18n_timezone_get_display_name_with_locale_id(i18n_timezone_h timezone, const char *locale_id,
+ char **display_name)
+{
+ retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ Locale locale(locale_id, 0, 0, 0);
+ *display_name = NULL;
+ UnicodeString displayName;
+
+ ((TimeZone *) timezone)->getDisplayName(locale, displayName);
+ const UChar *dn = displayName.getTerminatedBuffer();
+
+ retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER);
+ int32_t ulen = u_strlen(dn);
+
+ retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER);
+ *display_name = (char *)malloc(ulen + 1);
+
+ retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ i18n_ustring_copy_au(*display_name, (i18n_uchar*)dn);
+
+ return I18N_ERROR_NONE;
+}
+
+int i18n_timezone_get_display_name_with_type_locale_id(i18n_timezone_h timezone, i18n_ubool daylight,
+ i18n_timezone_display_type_e style,
+ const char *locale_id, char **display_name)
+{
+ retv_if(timezone == NULL || display_name == NULL, I18N_ERROR_INVALID_PARAMETER);
+
+ const Locale locale(locale_id, 0, 0, 0);
+ *display_name = NULL;
+ UnicodeString displayName;
+
+ ((TimeZone *) timezone)->getDisplayName((UBool) daylight, (TimeZone::EDisplayType) style,
+ locale, displayName);
+ const UChar *dn = displayName.getTerminatedBuffer();
+
+ retv_if(dn == NULL, I18N_ERROR_INVALID_PARAMETER);
+ int32_t ulen = u_strlen(dn);
+
+ retv_if(ulen <= 0, I18N_ERROR_INVALID_PARAMETER);
+ *display_name = (char *)malloc(ulen + 1);
+
+ retv_if(*display_name == NULL, I18N_ERROR_OUT_OF_MEMORY);
+
+ i18n_ustring_copy_au(*display_name, (i18n_uchar*)dn);
+
+ return I18N_ERROR_NONE;
+}