1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include
"nsISupports.idl"
8 [scriptable
, uuid(65944815-e9ae
-48bd
-a2bf
-f1108720950c
)]
9 interface mozIOSPreferences
: nsISupports
11 const long dateTimeFormatStyleNone
= 0;
12 const long dateTimeFormatStyleShort
= 1;
13 const long dateTimeFormatStyleMedium
= 2;
14 const long dateTimeFormatStyleLong
= 3;
15 const long dateTimeFormatStyleFull
= 4;
18 * Returns a list of locales used by the host environment for UI
21 * The result is a sorted list and we expect that the OS attempts to
22 * use the top locale from the list for which it has data.
24 * Each element of the list is a valid locale ID that can be passed to ICU
25 * and ECMA402 Intl APIs,
26 * At the same time each element is a valid BCP47 language tag that can be
27 * used for language negotiation.
29 * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
31 readonly attribute Array
<ACString
> systemLocales
;
34 * Returns a list of locales used by host environment for regional
35 * preferences internationalization.
37 * The result is a sorted list and we expect that the OS attempts to
38 * use the top locale from the list for which it has data.
40 * Each element of the list is a valid locale ID that can be passed to ICU
41 * and ECMA402 Intl APIs,
43 * Example: ["en-US", "de", "pl", "sr-Cyrl", "zh-Hans-HK"]
45 readonly attribute Array
<ACString
> regionalPrefsLocales
;
48 * Returns the best locale that the host environment is localized to.
50 * The result is a valid locale ID and it should be
51 * used for all APIs that do not handle language negotiation.
53 * In any scenario involving language negotiation, systemLocales should
54 * be preferred over the single value.
56 * Example: "zh-Hans-HK"
58 readonly attribute ACString systemLocale
;
61 * Returns the best possible date/time pattern for the host environment
62 * taking into account date/time regional settings user defined in the OS
65 * Notice, that depending on the OS it may take into account those settings
66 * for all locales, or only if the locale matches the OS locale.
68 * It takes two integer arguments that must be valid `dateTimeFormatStyle*`
69 * values (see constants defined above), and a string representing a
72 * It returns a string with a LDML date/time pattern.
74 * If no pattern can be retrieved from the host environment, it will
75 * lookup the best available pattern from ICU.
77 * Notice, this is a pretty unique method in this API in that it does
78 * more than look up into host environment.
79 * The reason for that is that constructing the right date/time pattern
80 * requires a lot of OS-specific logic and it ends up being easier to just
81 * handle all scenarios, including with cases where we fail to retrieve
82 * anything from the OS, here.
84 AUTF8String getDateTimePattern
(in long timeFormatStyle
,
85 in long dateFormatStyle
,
86 [optional] in ACString locale
);