tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

IntlObject.h (2487B)


      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 class JSLinearString;
     13 
     14 namespace js {
     15 
     16 extern const JSClass IntlClass;
     17 
     18 /**
     19 * Returns a plain object with calendar information for a single valid locale
     20 * (callers must perform this validation).  The object will have these
     21 * properties:
     22 *
     23 *   firstDayOfWeek
     24 *     an integer in the range 1=Monday to 7=Sunday indicating the day
     25 *     considered the first day of the week in calendars, e.g. 7 for en-US,
     26 *     1 for en-GB, 7 for bn-IN
     27 *   minDays
     28 *     an integer in the range of 1 to 7 indicating the minimum number
     29 *     of days required in the first week of the year, e.g. 1 for en-US,
     30 *     4 for de
     31 *   weekend
     32 *     an array with values in the range 1=Monday to 7=Sunday indicating the
     33 *     days of the week considered as part of the weekend, e.g. [6, 7] for en-US
     34 *     and en-GB, [7] for bn-IN (note that "weekend" is *not* necessarily two
     35 *     days)
     36 *
     37 * NOTE: "calendar" and "locale" properties are *not* added to the object.
     38 */
     39 [[nodiscard]] extern bool intl_GetCalendarInfo(JSContext* cx, unsigned argc,
     40                                               JS::Value* vp);
     41 
     42 /**
     43 * Compares a BCP 47 language tag against the locales in availableLocales and
     44 * returns the best available match -- or |undefined| if no match was found.
     45 * Uses the fallback mechanism of RFC 4647, section 3.4.
     46 *
     47 * The set of available locales consulted doesn't necessarily include the
     48 * default locale or any generalized forms of it (e.g. "de" is a more-general
     49 * form of "de-CH"). If you want to be sure to consider the default local and
     50 * its generalized forms (you usually will), pass the default locale as the
     51 * value of |defaultOrNull|; otherwise pass null.
     52 *
     53 * Spec: ECMAScript Internationalization API Specification, 9.2.2.
     54 * Spec: RFC 4647, section 3.4.
     55 *
     56 * Usage: result = intl_BestAvailableLocale("Collator", locale, defaultOrNull)
     57 */
     58 [[nodiscard]] extern bool intl_BestAvailableLocale(JSContext* cx, unsigned argc,
     59                                                   JS::Value* vp);
     60 }  // namespace js
     61 
     62 #endif /* builtin_intl_IntlObject_h */