| 1 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 |
|
| 5 |
/** |
| 6 |
* 8.2.1 Intl.getCanonicalLocales ( locales ) |
| 7 |
* |
| 8 |
* ES2017 Intl draft rev 947aa9a0c853422824a0c9510d8f09be3eb416b9 |
| 9 |
*/ |
| 10 |
function Intl_getCanonicalLocales(locales) { |
| 11 |
// Steps 1-2. |
| 12 |
return CanonicalizeLocaleList(locales); |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Intl.supportedValuesOf ( key ) |
| 17 |
*/ |
| 18 |
function Intl_supportedValuesOf(key) { |
| 19 |
// Step 1. |
| 20 |
key = ToString(key); |
| 21 |
|
| 22 |
// Steps 2-9. |
| 23 |
return intl_SupportedValuesOf(key); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* This function is a custom function in the style of the standard Intl.* |
| 28 |
* functions, that isn't part of any spec or proposal yet. |
| 29 |
* |
| 30 |
* Returns an object with the following properties: |
| 31 |
* locale: |
| 32 |
* The actual resolved locale. |
| 33 |
* |
| 34 |
* calendar: |
| 35 |
* The default calendar of the resolved locale. |
| 36 |
* |
| 37 |
* firstDayOfWeek: |
| 38 |
* The first day of the week for the resolved locale. |
| 39 |
* |
| 40 |
* minDays: |
| 41 |
* The minimum number of days in a week for the resolved locale. |
| 42 |
* |
| 43 |
* weekend: |
| 44 |
* The days of the week considered as the weekend for the resolved locale. |
| 45 |
* |
| 46 |
* Days are encoded as integers in the range 1=Monday to 7=Sunday. |
| 47 |
*/ |
| 48 |
function Intl_getCalendarInfo(locales) { |
| 49 |
// 1. Let requestLocales be ? CanonicalizeLocaleList(locales). |
| 50 |
var requestedLocales = CanonicalizeLocaleList(locales); |
| 51 |
|
| 52 |
var DateTimeFormat = dateTimeFormatInternalProperties; |
| 53 |
|
| 54 |
// 2. Let localeData be %DateTimeFormat%.[[localeData]]. |
| 55 |
var localeData = DateTimeFormat.localeData; |
| 56 |
|
| 57 |
// 3. Let localeOpt be a new Record. |
| 58 |
var localeOpt = new_Record(); |
| 59 |
|
| 60 |
// 4. Set localeOpt.[[localeMatcher]] to "best fit". |
| 61 |
localeOpt.localeMatcher = "best fit"; |
| 62 |
|
| 63 |
// 5. Let r be ResolveLocale(%DateTimeFormat%.[[availableLocales]], |
| 64 |
// requestedLocales, localeOpt, |
| 65 |
// %DateTimeFormat%.[[relevantExtensionKeys]], localeData). |
| 66 |
var r = ResolveLocale( |
| 67 |
"DateTimeFormat", |
| 68 |
requestedLocales, |
| 69 |
localeOpt, |
| 70 |
DateTimeFormat.relevantExtensionKeys, |
| 71 |
localeData |
| 72 |
); |
| 73 |
|
| 74 |
// 6. Let result be GetCalendarInfo(r.[[locale]]). |
| 75 |
var result = intl_GetCalendarInfo(r.locale); |
| 76 |
DefineDataProperty(result, "calendar", r.ca); |
| 77 |
DefineDataProperty(result, "locale", r.locale); |
| 78 |
|
| 79 |
// 7. Return result. |
| 80 |
return result; |
| 81 |
} |