| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef builtin_intl_IntlObject_h |
| 8 |
#define builtin_intl_IntlObject_h |
| 9 |
|
| 10 |
#include "js/TypeDecls.h" |
| 11 |
|
| 12 |
namespace js { |
| 13 |
|
| 14 |
extern const JSClass IntlClass; |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns a plain object with calendar information for a single valid locale |
| 18 |
* (callers must perform this validation). The object will have these |
| 19 |
* properties: |
| 20 |
* |
| 21 |
* firstDayOfWeek |
| 22 |
* an integer in the range 1=Monday to 7=Sunday indicating the day |
| 23 |
* considered the first day of the week in calendars, e.g. 7 for en-US, |
| 24 |
* 1 for en-GB, 7 for bn-IN |
| 25 |
* minDays |
| 26 |
* an integer in the range of 1 to 7 indicating the minimum number |
| 27 |
* of days required in the first week of the year, e.g. 1 for en-US, |
| 28 |
* 4 for de |
| 29 |
* weekend |
| 30 |
* an array with values in the range 1=Monday to 7=Sunday indicating the |
| 31 |
* days of the week considered as part of the weekend, e.g. [6, 7] for en-US |
| 32 |
* and en-GB, [7] for bn-IN (note that "weekend" is *not* necessarily two |
| 33 |
* days) |
| 34 |
* |
| 35 |
* NOTE: "calendar" and "locale" properties are *not* added to the object. |
| 36 |
*/ |
| 37 |
[[nodiscard]] extern bool intl_GetCalendarInfo(JSContext* cx, unsigned argc, |
| 38 |
JS::Value* vp); |
| 39 |
|
| 40 |
/** |
| 41 |
* Compares a BCP 47 language tag against the locales in availableLocales and |
| 42 |
* returns the best available match -- or |undefined| if no match was found. |
| 43 |
* Uses the fallback mechanism of RFC 4647, section 3.4. |
| 44 |
* |
| 45 |
* The set of available locales consulted doesn't necessarily include the |
| 46 |
* default locale or any generalized forms of it (e.g. "de" is a more-general |
| 47 |
* form of "de-CH"). If you want to be sure to consider the default local and |
| 48 |
* its generalized forms (you usually will), pass the default locale as the |
| 49 |
* value of |defaultOrNull|; otherwise pass null. |
| 50 |
* |
| 51 |
* Spec: ECMAScript Internationalization API Specification, 9.2.2. |
| 52 |
* Spec: RFC 4647, section 3.4. |
| 53 |
* |
| 54 |
* Usage: result = intl_BestAvailableLocale("Collator", locale, defaultOrNull) |
| 55 |
*/ |
| 56 |
[[nodiscard]] extern bool intl_BestAvailableLocale(JSContext* cx, unsigned argc, |
| 57 |
JS::Value* vp); |
| 58 |
|
| 59 |
/** |
| 60 |
* Return the supported locale for the input locale if ICU supports that locale |
| 61 |
* (perhaps via fallback, e.g. supporting "de-CH" through "de" support implied |
| 62 |
* by a "de-DE" locale). Otherwise uses the last-ditch locale. |
| 63 |
* |
| 64 |
* Usage: result = intl_supportedLocaleOrFallback(locale) |
| 65 |
*/ |
| 66 |
[[nodiscard]] extern bool intl_supportedLocaleOrFallback(JSContext* cx, |
| 67 |
unsigned argc, |
| 68 |
JS::Value* vp); |
| 69 |
|
| 70 |
/** |
| 71 |
* Returns the list of supported values for the given key. Throws a RangeError |
| 72 |
* if the key isn't one of {"calendar", "collation", "currency", |
| 73 |
* "numberingSystem", "timeZone", "unit"}. |
| 74 |
* |
| 75 |
* Usage: list = intl_SupportedValuesOf(key) |
| 76 |
*/ |
| 77 |
[[nodiscard]] extern bool intl_SupportedValuesOf(JSContext* cx, unsigned argc, |
| 78 |
JS::Value* vp); |
| 79 |
|
| 80 |
} // namespace js |
| 81 |
|
| 82 |
#endif /* builtin_intl_IntlObject_h */ |