diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-30 18:58:51 +0200 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-30 18:58:51 +0200 |
commit | c4aadf04aa9c089c6251478f23e941bfa03b3cad (patch) | |
tree | 10081190e622456c1515d4a00f6f99cec52fe44e /js/src/builtin/Intl.h | |
parent | e25430117a67f5c898e5e9388ebd44b185d469ab (diff) | |
download | UXP-c4aadf04aa9c089c6251478f23e941bfa03b3cad.tar UXP-c4aadf04aa9c089c6251478f23e941bfa03b3cad.tar.gz UXP-c4aadf04aa9c089c6251478f23e941bfa03b3cad.tar.lz UXP-c4aadf04aa9c089c6251478f23e941bfa03b3cad.tar.xz UXP-c4aadf04aa9c089c6251478f23e941bfa03b3cad.zip |
Bug 1287677 - Add mozIntl.getDisplayNames API
Diffstat (limited to 'js/src/builtin/Intl.h')
-rw-r--r-- | js/src/builtin/Intl.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/js/src/builtin/Intl.h b/js/src/builtin/Intl.h index 54764605b..b2197060d 100644 --- a/js/src/builtin/Intl.h +++ b/js/src/builtin/Intl.h @@ -387,6 +387,48 @@ intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp); extern MOZ_MUST_USE bool intl_GetCalendarInfo(JSContext* cx, unsigned argc, Value* vp); +/** + * Returns an Array with CLDR-based fields display names. + * The function takes three arguments: + * + * locale + * BCP47 compliant locale string + * style + * A string with values: long or short or narrow + * keys + * An array or path-like strings that identify keys to be returned + * At the moment the following types of keys are supported: + * + * 'dates/fields/{year|month|week|day}' + * 'dates/gregorian/months/{january|...|december}' + * 'dates/gregorian/weekdays/{sunday|...|saturday}' + * 'dates/gregorian/dayperiods/{am|pm}' + * + * Example: + * + * let info = intl_ComputeDisplayNames( + * 'en-US', + * 'long', + * [ + * 'dates/fields/year', + * 'dates/gregorian/months/january', + * 'dates/gregorian/weekdays/monday', + * 'dates/gregorian/dayperiods/am', + * ] + * ); + * + * Returned value: + * + * [ + * 'year', + * 'January', + * 'Monday', + * 'AM' + * ] + */ +extern MOZ_MUST_USE bool +intl_ComputeDisplayNames(JSContext* cx, unsigned argc, Value* vp); + #if ENABLE_INTL_API /** * Cast char16_t* strings to UChar* strings used by ICU. @@ -402,6 +444,18 @@ Char16ToUChar(char16_t* chars) { return reinterpret_cast<UChar*>(chars); } + +inline char16_t* +UCharToChar16(UChar* chars) +{ + return reinterpret_cast<char16_t*>(chars); +} + +inline const char16_t* +UCharToChar16(const UChar* chars) +{ + return reinterpret_cast<const char16_t*>(chars); +} #endif // ENABLE_INTL_API } // namespace js |