addon-sdk/source/lib/sdk/l10n/plural-rules.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // This file is automatically generated with /python-lib/plural-rules-generator.py
michael@0 6 // Fetching data from: http://unicode.org/repos/cldr/trunk/common/supplemental/plurals.xml
michael@0 7
michael@0 8 // Mapping of short locale name == to == > rule index in following list
michael@0 9
michael@0 10 module.metadata = {
michael@0 11 "stability": "unstable"
michael@0 12 };
michael@0 13
michael@0 14 const LOCALES_TO_RULES = {
michael@0 15 "af": 3,
michael@0 16 "ak": 4,
michael@0 17 "am": 4,
michael@0 18 "ar": 1,
michael@0 19 "asa": 3,
michael@0 20 "az": 0,
michael@0 21 "be": 11,
michael@0 22 "bem": 3,
michael@0 23 "bez": 3,
michael@0 24 "bg": 3,
michael@0 25 "bh": 4,
michael@0 26 "bm": 0,
michael@0 27 "bn": 3,
michael@0 28 "bo": 0,
michael@0 29 "br": 20,
michael@0 30 "brx": 3,
michael@0 31 "bs": 11,
michael@0 32 "ca": 3,
michael@0 33 "cgg": 3,
michael@0 34 "chr": 3,
michael@0 35 "cs": 12,
michael@0 36 "cy": 17,
michael@0 37 "da": 3,
michael@0 38 "de": 3,
michael@0 39 "dv": 3,
michael@0 40 "dz": 0,
michael@0 41 "ee": 3,
michael@0 42 "el": 3,
michael@0 43 "en": 3,
michael@0 44 "eo": 3,
michael@0 45 "es": 3,
michael@0 46 "et": 3,
michael@0 47 "eu": 3,
michael@0 48 "fa": 0,
michael@0 49 "ff": 5,
michael@0 50 "fi": 3,
michael@0 51 "fil": 4,
michael@0 52 "fo": 3,
michael@0 53 "fr": 5,
michael@0 54 "fur": 3,
michael@0 55 "fy": 3,
michael@0 56 "ga": 8,
michael@0 57 "gd": 24,
michael@0 58 "gl": 3,
michael@0 59 "gsw": 3,
michael@0 60 "gu": 3,
michael@0 61 "guw": 4,
michael@0 62 "gv": 23,
michael@0 63 "ha": 3,
michael@0 64 "haw": 3,
michael@0 65 "he": 2,
michael@0 66 "hi": 4,
michael@0 67 "hr": 11,
michael@0 68 "hu": 0,
michael@0 69 "id": 0,
michael@0 70 "ig": 0,
michael@0 71 "ii": 0,
michael@0 72 "is": 3,
michael@0 73 "it": 3,
michael@0 74 "iu": 7,
michael@0 75 "ja": 0,
michael@0 76 "jmc": 3,
michael@0 77 "jv": 0,
michael@0 78 "ka": 0,
michael@0 79 "kab": 5,
michael@0 80 "kaj": 3,
michael@0 81 "kcg": 3,
michael@0 82 "kde": 0,
michael@0 83 "kea": 0,
michael@0 84 "kk": 3,
michael@0 85 "kl": 3,
michael@0 86 "km": 0,
michael@0 87 "kn": 0,
michael@0 88 "ko": 0,
michael@0 89 "ksb": 3,
michael@0 90 "ksh": 21,
michael@0 91 "ku": 3,
michael@0 92 "kw": 7,
michael@0 93 "lag": 18,
michael@0 94 "lb": 3,
michael@0 95 "lg": 3,
michael@0 96 "ln": 4,
michael@0 97 "lo": 0,
michael@0 98 "lt": 10,
michael@0 99 "lv": 6,
michael@0 100 "mas": 3,
michael@0 101 "mg": 4,
michael@0 102 "mk": 16,
michael@0 103 "ml": 3,
michael@0 104 "mn": 3,
michael@0 105 "mo": 9,
michael@0 106 "mr": 3,
michael@0 107 "ms": 0,
michael@0 108 "mt": 15,
michael@0 109 "my": 0,
michael@0 110 "nah": 3,
michael@0 111 "naq": 7,
michael@0 112 "nb": 3,
michael@0 113 "nd": 3,
michael@0 114 "ne": 3,
michael@0 115 "nl": 3,
michael@0 116 "nn": 3,
michael@0 117 "no": 3,
michael@0 118 "nr": 3,
michael@0 119 "nso": 4,
michael@0 120 "ny": 3,
michael@0 121 "nyn": 3,
michael@0 122 "om": 3,
michael@0 123 "or": 3,
michael@0 124 "pa": 3,
michael@0 125 "pap": 3,
michael@0 126 "pl": 13,
michael@0 127 "ps": 3,
michael@0 128 "pt": 3,
michael@0 129 "rm": 3,
michael@0 130 "ro": 9,
michael@0 131 "rof": 3,
michael@0 132 "ru": 11,
michael@0 133 "rwk": 3,
michael@0 134 "sah": 0,
michael@0 135 "saq": 3,
michael@0 136 "se": 7,
michael@0 137 "seh": 3,
michael@0 138 "ses": 0,
michael@0 139 "sg": 0,
michael@0 140 "sh": 11,
michael@0 141 "shi": 19,
michael@0 142 "sk": 12,
michael@0 143 "sl": 14,
michael@0 144 "sma": 7,
michael@0 145 "smi": 7,
michael@0 146 "smj": 7,
michael@0 147 "smn": 7,
michael@0 148 "sms": 7,
michael@0 149 "sn": 3,
michael@0 150 "so": 3,
michael@0 151 "sq": 3,
michael@0 152 "sr": 11,
michael@0 153 "ss": 3,
michael@0 154 "ssy": 3,
michael@0 155 "st": 3,
michael@0 156 "sv": 3,
michael@0 157 "sw": 3,
michael@0 158 "syr": 3,
michael@0 159 "ta": 3,
michael@0 160 "te": 3,
michael@0 161 "teo": 3,
michael@0 162 "th": 0,
michael@0 163 "ti": 4,
michael@0 164 "tig": 3,
michael@0 165 "tk": 3,
michael@0 166 "tl": 4,
michael@0 167 "tn": 3,
michael@0 168 "to": 0,
michael@0 169 "tr": 0,
michael@0 170 "ts": 3,
michael@0 171 "tzm": 22,
michael@0 172 "uk": 11,
michael@0 173 "ur": 3,
michael@0 174 "ve": 3,
michael@0 175 "vi": 0,
michael@0 176 "vun": 3,
michael@0 177 "wa": 4,
michael@0 178 "wae": 3,
michael@0 179 "wo": 0,
michael@0 180 "xh": 3,
michael@0 181 "xog": 3,
michael@0 182 "yo": 0,
michael@0 183 "zh": 0,
michael@0 184 "zu": 3
michael@0 185 };
michael@0 186
michael@0 187 // Utility functions for plural rules methods
michael@0 188 function isIn(n, list) list.indexOf(n) !== -1;
michael@0 189 function isBetween(n, start, end) start <= n && n <= end;
michael@0 190
michael@0 191 // List of all plural rules methods, that maps an integer to the plural form name to use
michael@0 192 const RULES = {
michael@0 193 "0": function (n) {
michael@0 194
michael@0 195 return "other"
michael@0 196 },
michael@0 197 "1": function (n) {
michael@0 198 if ((isBetween((n % 100), 3, 10)))
michael@0 199 return "few";
michael@0 200 if (n == 0)
michael@0 201 return "zero";
michael@0 202 if ((isBetween((n % 100), 11, 99)))
michael@0 203 return "many";
michael@0 204 if (n == 2)
michael@0 205 return "two";
michael@0 206 if (n == 1)
michael@0 207 return "one";
michael@0 208 return "other"
michael@0 209 },
michael@0 210 "2": function (n) {
michael@0 211 if (n != 0 && (n % 10) == 0)
michael@0 212 return "many";
michael@0 213 if (n == 2)
michael@0 214 return "two";
michael@0 215 if (n == 1)
michael@0 216 return "one";
michael@0 217 return "other"
michael@0 218 },
michael@0 219 "3": function (n) {
michael@0 220 if (n == 1)
michael@0 221 return "one";
michael@0 222 return "other"
michael@0 223 },
michael@0 224 "4": function (n) {
michael@0 225 if ((isBetween(n, 0, 1)))
michael@0 226 return "one";
michael@0 227 return "other"
michael@0 228 },
michael@0 229 "5": function (n) {
michael@0 230 if ((isBetween(n, 0, 2)) && n != 2)
michael@0 231 return "one";
michael@0 232 return "other"
michael@0 233 },
michael@0 234 "6": function (n) {
michael@0 235 if (n == 0)
michael@0 236 return "zero";
michael@0 237 if ((n % 10) == 1 && (n % 100) != 11)
michael@0 238 return "one";
michael@0 239 return "other"
michael@0 240 },
michael@0 241 "7": function (n) {
michael@0 242 if (n == 2)
michael@0 243 return "two";
michael@0 244 if (n == 1)
michael@0 245 return "one";
michael@0 246 return "other"
michael@0 247 },
michael@0 248 "8": function (n) {
michael@0 249 if ((isBetween(n, 3, 6)))
michael@0 250 return "few";
michael@0 251 if ((isBetween(n, 7, 10)))
michael@0 252 return "many";
michael@0 253 if (n == 2)
michael@0 254 return "two";
michael@0 255 if (n == 1)
michael@0 256 return "one";
michael@0 257 return "other"
michael@0 258 },
michael@0 259 "9": function (n) {
michael@0 260 if (n == 0 || n != 1 && (isBetween((n % 100), 1, 19)))
michael@0 261 return "few";
michael@0 262 if (n == 1)
michael@0 263 return "one";
michael@0 264 return "other"
michael@0 265 },
michael@0 266 "10": function (n) {
michael@0 267 if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19)))
michael@0 268 return "few";
michael@0 269 if ((n % 10) == 1 && !(isBetween((n % 100), 11, 19)))
michael@0 270 return "one";
michael@0 271 return "other"
michael@0 272 },
michael@0 273 "11": function (n) {
michael@0 274 if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
michael@0 275 return "few";
michael@0 276 if ((n % 10) == 0 || (isBetween((n % 10), 5, 9)) || (isBetween((n % 100), 11, 14)))
michael@0 277 return "many";
michael@0 278 if ((n % 10) == 1 && (n % 100) != 11)
michael@0 279 return "one";
michael@0 280 return "other"
michael@0 281 },
michael@0 282 "12": function (n) {
michael@0 283 if ((isBetween(n, 2, 4)))
michael@0 284 return "few";
michael@0 285 if (n == 1)
michael@0 286 return "one";
michael@0 287 return "other"
michael@0 288 },
michael@0 289 "13": function (n) {
michael@0 290 if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14)))
michael@0 291 return "few";
michael@0 292 if (n != 1 && (isBetween((n % 10), 0, 1)) || (isBetween((n % 10), 5, 9)) || (isBetween((n % 100), 12, 14)))
michael@0 293 return "many";
michael@0 294 if (n == 1)
michael@0 295 return "one";
michael@0 296 return "other"
michael@0 297 },
michael@0 298 "14": function (n) {
michael@0 299 if ((isBetween((n % 100), 3, 4)))
michael@0 300 return "few";
michael@0 301 if ((n % 100) == 2)
michael@0 302 return "two";
michael@0 303 if ((n % 100) == 1)
michael@0 304 return "one";
michael@0 305 return "other"
michael@0 306 },
michael@0 307 "15": function (n) {
michael@0 308 if (n == 0 || (isBetween((n % 100), 2, 10)))
michael@0 309 return "few";
michael@0 310 if ((isBetween((n % 100), 11, 19)))
michael@0 311 return "many";
michael@0 312 if (n == 1)
michael@0 313 return "one";
michael@0 314 return "other"
michael@0 315 },
michael@0 316 "16": function (n) {
michael@0 317 if ((n % 10) == 1 && n != 11)
michael@0 318 return "one";
michael@0 319 return "other"
michael@0 320 },
michael@0 321 "17": function (n) {
michael@0 322 if (n == 3)
michael@0 323 return "few";
michael@0 324 if (n == 0)
michael@0 325 return "zero";
michael@0 326 if (n == 6)
michael@0 327 return "many";
michael@0 328 if (n == 2)
michael@0 329 return "two";
michael@0 330 if (n == 1)
michael@0 331 return "one";
michael@0 332 return "other"
michael@0 333 },
michael@0 334 "18": function (n) {
michael@0 335 if (n == 0)
michael@0 336 return "zero";
michael@0 337 if ((isBetween(n, 0, 2)) && n != 0 && n != 2)
michael@0 338 return "one";
michael@0 339 return "other"
michael@0 340 },
michael@0 341 "19": function (n) {
michael@0 342 if ((isBetween(n, 2, 10)))
michael@0 343 return "few";
michael@0 344 if ((isBetween(n, 0, 1)))
michael@0 345 return "one";
michael@0 346 return "other"
michael@0 347 },
michael@0 348 "20": function (n) {
michael@0 349 if ((isBetween((n % 10), 3, 4) || ((n % 10) == 9)) && !(isBetween((n % 100), 10, 19) || isBetween((n % 100), 70, 79) || isBetween((n % 100), 90, 99)))
michael@0 350 return "few";
michael@0 351 if ((n % 1000000) == 0 && n != 0)
michael@0 352 return "many";
michael@0 353 if ((n % 10) == 2 && !isIn((n % 100), [12, 72, 92]))
michael@0 354 return "two";
michael@0 355 if ((n % 10) == 1 && !isIn((n % 100), [11, 71, 91]))
michael@0 356 return "one";
michael@0 357 return "other"
michael@0 358 },
michael@0 359 "21": function (n) {
michael@0 360 if (n == 0)
michael@0 361 return "zero";
michael@0 362 if (n == 1)
michael@0 363 return "one";
michael@0 364 return "other"
michael@0 365 },
michael@0 366 "22": function (n) {
michael@0 367 if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99)))
michael@0 368 return "one";
michael@0 369 return "other"
michael@0 370 },
michael@0 371 "23": function (n) {
michael@0 372 if ((isBetween((n % 10), 1, 2)) || (n % 20) == 0)
michael@0 373 return "one";
michael@0 374 return "other"
michael@0 375 },
michael@0 376 "24": function (n) {
michael@0 377 if ((isBetween(n, 3, 10) || isBetween(n, 13, 19)))
michael@0 378 return "few";
michael@0 379 if (isIn(n, [2, 12]))
michael@0 380 return "two";
michael@0 381 if (isIn(n, [1, 11]))
michael@0 382 return "one";
michael@0 383 return "other"
michael@0 384 },
michael@0 385 };
michael@0 386
michael@0 387 /**
michael@0 388 * Return a function that gives the plural form name for a given integer
michael@0 389 * for the specified `locale`
michael@0 390 * let fun = getRulesForLocale('en');
michael@0 391 * fun(1) -> 'one'
michael@0 392 * fun(0) -> 'other'
michael@0 393 * fun(1000) -> 'other'
michael@0 394 */
michael@0 395 exports.getRulesForLocale = function getRulesForLocale(locale) {
michael@0 396 let index = LOCALES_TO_RULES[locale];
michael@0 397 if (!(index in RULES)) {
michael@0 398 console.warn('Plural form unknown for locale "' + locale + '"');
michael@0 399 return function () { return "other"; };
michael@0 400 }
michael@0 401 return RULES[index];
michael@0 402 }
michael@0 403

mercurial