summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/Intl.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-12-22 20:32:56 +0000
committerMoonchild <moonchild@palemoon.org>2020-12-22 20:32:56 +0000
commit25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4 (patch)
tree7c410dbb5d672661bf0a567736501ec3f5ef5191 /js/src/builtin/Intl.h
parent911cbcd1af7d8becf9694e3b51ce773908e1a93d (diff)
downloadUXP-25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4.tar
UXP-25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4.tar.gz
UXP-25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4.tar.lz
UXP-25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4.tar.xz
UXP-25b6703e956a33e0ecd8bdc18f423e5eb5dd09d4.zip
Issue #1701 - Implement Intl.PluralRules API
Diffstat (limited to 'js/src/builtin/Intl.h')
-rw-r--r--js/src/builtin/Intl.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/js/src/builtin/Intl.h b/js/src/builtin/Intl.h
index 5384d9be1..fd1fc5da6 100644
--- a/js/src/builtin/Intl.h
+++ b/js/src/builtin/Intl.h
@@ -358,6 +358,54 @@ intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool
intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp);
+/******************** PluralRules ********************/
+
+/**
+ * Returns a new PluralRules instance.
+ * Self-hosted code cannot cache this constructor (as it does for others in
+ * Utilities.js) because it is initialized after self-hosted code is compiled.
+ *
+ * Usage: pluralRules = intl_PluralRules(locales, options)
+ */
+extern MOZ_MUST_USE bool
+intl_PluralRules(JSContext* cx, unsigned argc, Value* vp);
+
+/**
+ * Returns an object indicating the supported locales for plural rules
+ * by having a true-valued property for each such locale with the
+ * canonicalized language tag as the property name. The object has no
+ * prototype.
+ *
+ * Usage: availableLocales = intl_PluralRules_availableLocales()
+ */
+extern MOZ_MUST_USE bool
+intl_PluralRules_availableLocales(JSContext* cx, unsigned argc, Value* vp);
+
+/**
+ * Returns a plural rule for the number x according to the effective
+ * locale and the formatting options of the given PluralRules.
+ *
+ * A plural rule is a grammatical category that expresses count distinctions
+ * (such as "one", "two", "few" etc.).
+ *
+ * Usage: rule = intl_SelectPluralRule(pluralRules, x)
+ */
+extern MOZ_MUST_USE bool
+intl_SelectPluralRule(JSContext* cx, unsigned argc, Value* vp);
+
+/**
+ * Returns an array of plural rules categories for a given
+ * locale and type.
+ *
+ * Usage: categories = intl_GetPluralCategories(locale, type)
+ *
+ * Example:
+ *
+ * intl_getPluralCategories('pl', 'cardinal'); // ['one', 'few', 'many', 'other']
+ */
+extern MOZ_MUST_USE bool
+intl_GetPluralCategories(JSContext* cx, unsigned argc, Value* vp);
+
/**
* Returns a plain object with calendar information for a single valid locale
* (callers must perform this validation). The object will have these