1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef builtin_intl_IntlObject_h
#define builtin_intl_IntlObject_h
#include "mozilla/Attributes.h"
#include "js/RootingAPI.h"
struct JSContext;
class JSObject;
namespace JS { class Value; }
namespace js {
/**
* Initializes the Intl Object and its standard built-in properties.
* Spec: ECMAScript Internationalization API Specification, 8.0, 8.1
*/
extern JSObject*
InitIntlClass(JSContext* cx, JS::Handle<JSObject*> obj);
/*
* The following functions are for use by self-hosted code.
*/
/**
* Returns a plain object with calendar information for a single valid locale
* (callers must perform this validation). The object will have these
* properties:
*
* firstDayOfWeek
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the first day of the week in calendars, e.g. 1 for en-US,
* 2 for en-GB, 1 for bn-IN
* minDays
* an integer in the range of 1 to 7 indicating the minimum number
* of days required in the first week of the year, e.g. 1 for en-US, 4 for de
* weekendStart
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the beginning of a weekend, e.g. 7 for en-US, 7 for en-GB,
* 1 for bn-IN
* weekendEnd
* an integer in the range 1=Sunday to 7=Saturday indicating the day
* considered the end of a weekend, e.g. 1 for en-US, 1 for en-GB,
* 1 for bn-IN (note that "weekend" is *not* necessarily two days)
*
* NOTE: "calendar" and "locale" properties are *not* added to the object.
*/
[[nodiscard]] extern bool
intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::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'
* ]
*/
[[nodiscard]] extern bool
intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp);
/**
* Compares a BCP 47 language tag against the locales in availableLocales and
* returns the best available match -- or |undefined| if no match was found.
* Uses the fallback mechanism of RFC 4647, section 3.4.
*
* The set of available locales consulted doesn't necessarily include the
* default locale or any generalized forms of it (e.g. "de" is a more-general
* form of "de-CH"). If you want to be sure to consider the default local and
* its generalized forms (you usually will), pass the default locale as the
* value of |defaultOrNull|; otherwise pass null.
*
* Spec: ECMAScript Internationalization API Specification, 9.2.2.
* Spec: RFC 4647, section 3.4.
*
* Usage: result = intl_BestAvailableLocale("Collator", locale, defaultOrNull)
*/
[[nodiscard]] extern bool
intl_BestAvailableLocale(JSContext* cx, unsigned argc, JS::Value* vp);
/**
* Returns the input locale in its canonicalized form if ICU supports that
* locale (perhaps via fallback, e.g. supporting "de-ZA" through "de" support
* implied by a "de-DE" locale). Otherwise uses the last-ditch locale.
*
* Usage: result = intl_supportedLocaleOrFallback(locale)
*/
[[nodiscard]] extern bool
intl_supportedLocaleOrFallback(JSContext* cx, unsigned argc, JS::Value* vp);
} // namespace js
#endif /* builtin_intl_IntlObject_h */
|