(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.MessageFormat = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 1 ? arguments[1] : {}, parser = this, peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = function(st) { return { type: 'messageFormatPattern', statements: st }; }, peg$c1 = "{", peg$c2 = { type: "literal", value: "{", description: "\"{\"" }, peg$c3 = ",", peg$c4 = { type: "literal", value: ",", description: "\",\"" }, peg$c5 = "}", peg$c6 = { type: "literal", value: "}", description: "\"}\"" }, peg$c7 = function(argIdx, efmt) { var res = { type: "messageFormatElement", argumentIndex: argIdx }; if (efmt && efmt.length) { res.elementFormat = efmt[1]; } else { res.output = true; } return res; }, peg$c8 = "plural", peg$c9 = { type: "literal", value: "plural", description: "\"plural\"" }, peg$c10 = function(t, s) { return { type: "elementFormat", key: t, val: s }; }, peg$c11 = "selectordinal", peg$c12 = { type: "literal", value: "selectordinal", description: "\"selectordinal\"" }, peg$c13 = "select", peg$c14 = { type: "literal", value: "select", description: "\"select\"" }, peg$c15 = function(t, p) { return { type: "elementFormat", key: t, val: p }; }, peg$c16 = function(op, pf) { return { type: "pluralFormatPattern", pluralForms: pf, offset: op || 0 }; }, peg$c17 = "offset", peg$c18 = { type: "literal", value: "offset", description: "\"offset\"" }, peg$c19 = ":", peg$c20 = { type: "literal", value: ":", description: "\":\"" }, peg$c21 = function(d) { return d; }, peg$c22 = function(k, mfp) { return { key: k, val: mfp }; }, peg$c23 = function(i) { return i; }, peg$c24 = "=", peg$c25 = { type: "literal", value: "=", description: "\"=\"" }, peg$c26 = function(pf) { return { type: "selectFormatPattern", pluralForms: pf }; }, peg$c27 = function(p) { return p; }, peg$c28 = "#", peg$c29 = { type: "literal", value: "#", description: "\"#\"" }, peg$c30 = function() { return {type: 'octothorpe'}; }, peg$c31 = function(s) { return { type: "string", val: s.join('') }; }, peg$c32 = { type: "other", description: "identifier" }, peg$c33 = /^[0-9a-zA-Z$_]/, peg$c34 = { type: "class", value: "[0-9a-zA-Z$_]", description: "[0-9a-zA-Z$_]" }, peg$c35 = /^[^ \t\n\r,.+={}]/, peg$c36 = { type: "class", value: "[^ \\t\\n\\r,.+={}]", description: "[^ \\t\\n\\r,.+={}]" }, peg$c37 = function(s) { return s; }, peg$c38 = function(chars) { return chars.join(''); }, peg$c39 = /^[^{}#\\\0-\x1F \t\n\r]/, peg$c40 = { type: "class", value: "[^{}#\\\\\\0-\\x1F\\x7f \\t\\n\\r]", description: "[^{}#\\\\\\0-\\x1F\\x7f \\t\\n\\r]" }, peg$c41 = function(x) { return x; }, peg$c42 = "\\\\", peg$c43 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" }, peg$c44 = function() { return "\\"; }, peg$c45 = "\\#", peg$c46 = { type: "literal", value: "\\#", description: "\"\\\\#\"" }, peg$c47 = function() { return "#"; }, peg$c48 = "\\{", peg$c49 = { type: "literal", value: "\\{", description: "\"\\\\{\"" }, peg$c50 = function() { return "\u007B"; }, peg$c51 = "\\}", peg$c52 = { type: "literal", value: "\\}", description: "\"\\\\}\"" }, peg$c53 = function() { return "\u007D"; }, peg$c54 = "\\u", peg$c55 = { type: "literal", value: "\\u", description: "\"\\\\u\"" }, peg$c56 = function(h1, h2, h3, h4) { return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); }, peg$c57 = /^[0-9]/, peg$c58 = { type: "class", value: "[0-9]", description: "[0-9]" }, peg$c59 = function(ds) { //the number might start with 0 but must not be interpreted as an octal number //Hence, the base is passed to parseInt explicitely return parseInt((ds.join('')), 10); }, peg$c60 = /^[0-9a-fA-F]/, peg$c61 = { type: "class", value: "[0-9a-fA-F]", description: "[0-9a-fA-F]" }, peg$c62 = { type: "other", description: "whitespace" }, peg$c63 = function(w) { return w.join(''); }, peg$c64 = /^[ \t\n\r]/, peg$c65 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" }, peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1, seenCR: false }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description) { throw peg$buildException( null, [{ type: "other", description: description }], input.substring(peg$savedPos, peg$currPos), peg$computeLocation(peg$savedPos, peg$currPos) ); } function error(message) { throw peg$buildException( message, null, input.substring(peg$savedPos, peg$currPos), peg$computeLocation(peg$savedPos, peg$currPos) ); } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos], p, ch; if (details) { return details; } else { p = pos - 1; while (!peg$posDetailsCache[p]) { p--; } details = peg$posDetailsCache[p]; details = { line: details.line, column: details.column, seenCR: details.seenCR }; while (p < pos) { ch = input.charAt(p); if (ch === "\n") { if (!details.seenCR) { details.line++; } details.column = 1; details.seenCR = false; } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { details.line++; details.column = 1; details.seenCR = true; } else { details.column++; details.seenCR = false; } p++; } peg$posDetailsCache[pos] = details; return details; } } function peg$computeLocation(startPos, endPos) { var startPosDetails = peg$computePosDetails(startPos), endPosDetails = peg$computePosDetails(endPos); return { start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected); } function peg$buildException(message, expected, found, location) { function cleanupExpected(expected) { var i = 1; expected.sort(function(a, b) { if (a.description < b.description) { return -1; } else if (a.description > b.description) { return 1; } else { return 0; } }); while (i < expected.length) { if (expected[i - 1] === expected[i]) { expected.splice(i, 1); } else { i++; } } } function buildMessage(expected, found) { function stringEscape(s) { function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } return s .replace(/\\/g, '\\\\') .replace(/"/g, '\\"') .replace(/\x08/g, '\\b') .replace(/\t/g, '\\t') .replace(/\n/g, '\\n') .replace(/\f/g, '\\f') .replace(/\r/g, '\\r') .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) .replace(/[\u0100-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) .replace(/[\u1000-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); } var expectedDescs = new Array(expected.length), expectedDesc, foundDesc, i; for (i = 0; i < expected.length; i++) { expectedDescs[i] = expected[i].description; } expectedDesc = expected.length > 1 ? expectedDescs.slice(0, -1).join(", ") + " or " + expectedDescs[expected.length - 1] : expectedDescs[0]; foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; return "Expected " + expectedDesc + " but " + foundDesc + " found."; } if (expected !== null) { cleanupExpected(expected); } return new peg$SyntaxError( message !== null ? message : buildMessage(expected, found), expected, found, location ); } function peg$parsestart() { var s0; s0 = peg$parsemessageFormatPattern(); return s0; } function peg$parsemessageFormatPattern() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsemessageFormatElement(); if (s2 === peg$FAILED) { s2 = peg$parsestring(); if (s2 === peg$FAILED) { s2 = peg$parseoctothorpe(); } } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsemessageFormatElement(); if (s2 === peg$FAILED) { s2 = peg$parsestring(); if (s2 === peg$FAILED) { s2 = peg$parseoctothorpe(); } } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s1); } s0 = s1; return s0; } function peg$parsemessageFormatElement() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c1; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (s2 !== peg$FAILED) { s3 = peg$parseid(); if (s3 !== peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 44) { s5 = peg$c3; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s5 !== peg$FAILED) { s6 = peg$parseelementFormat(); if (s6 !== peg$FAILED) { s5 = [s5, s6]; s4 = s5; } else { peg$currPos = s4; s4 = peg$FAILED; } } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s6 = peg$c5; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s6 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c7(s3, s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseelementFormat() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 6) === peg$c8) { s2 = peg$c8; peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s4 = peg$c3; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parsepluralFormatPattern(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c10(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 13) === peg$c11) { s2 = peg$c11; peg$currPos += 13; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c12); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s4 = peg$c3; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parsepluralFormatPattern(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c10(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 6) === peg$c13) { s2 = peg$c13; peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s4 = peg$c3; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parseselectFormatPattern(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c10(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parseid(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parseargStylePattern(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parseargStylePattern(); } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c15(s2, s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } } } return s0; } function peg$parsepluralFormatPattern() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseoffsetPattern(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsepluralForm(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsepluralForm(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c16(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseoffsetPattern() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.substr(peg$currPos, 6) === peg$c17) { s2 = peg$c17; peg$currPos += 6; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s4 = peg$c19; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c20); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parsedigits(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c21(s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsepluralForm() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parsepluralKey(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s4 = peg$c1; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parsemessageFormatPattern(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s8 = peg$c5; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s8 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsepluralKey() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parseid(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 61) { s1 = peg$c24; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { s2 = peg$parsedigits(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c21(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parseselectFormatPattern() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parseselectForm(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseselectForm(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c26(s1); } s0 = s1; return s0; } function peg$parseselectForm() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$parseid(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s4 = peg$c1; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { s6 = peg$parsemessageFormatPattern(); if (s6 !== peg$FAILED) { s7 = peg$parse_(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s8 = peg$c5; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s8 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseargStylePattern() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s2 = peg$c3; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { s4 = peg$parseid(); if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c27(s4); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseoctothorpe() { var s0, s1; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 35) { s1 = peg$c28; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c30(); } s0 = s1; return s0; } function peg$parsestring() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsechars(); if (s2 === peg$FAILED) { s2 = peg$parsewhitespace(); } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsechars(); if (s2 === peg$FAILED) { s2 = peg$parsewhitespace(); } } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c31(s1); } s0 = s1; return s0; } function peg$parseid() { var s0, s1, s2, s3, s4, s5, s6; peg$silentFails++; s0 = peg$currPos; s1 = peg$parse_(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$currPos; if (peg$c33.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s4 !== peg$FAILED) { s5 = []; if (peg$c35.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } while (s6 !== peg$FAILED) { s5.push(s6); if (peg$c35.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } } if (s5 !== peg$FAILED) { s4 = [s4, s5]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s2 = input.substring(s2, peg$currPos); } else { s2 = s3; } if (s2 !== peg$FAILED) { s3 = peg$parse_(); if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c37(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } return s0; } function peg$parsechars() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parsechar(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsechar(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c38(s1); } s0 = s1; return s0; } function peg$parsechar() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; if (peg$c39.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c40); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c41(s1); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c42) { s1 = peg$c42; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c44(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c45) { s1 = peg$c45; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c47(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c48) { s1 = peg$c48; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c49); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c50(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c51) { s1 = peg$c51; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c53(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c54) { s1 = peg$c54; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s1 !== peg$FAILED) { s2 = peg$parsehexDigit(); if (s2 !== peg$FAILED) { s3 = peg$parsehexDigit(); if (s3 !== peg$FAILED) { s4 = peg$parsehexDigit(); if (s4 !== peg$FAILED) { s5 = peg$parsehexDigit(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c56(s2, s3, s4, s5); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } } } } } return s0; } function peg$parsedigits() { var s0, s1, s2; s0 = peg$currPos; s1 = []; if (peg$c57.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c58); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c57.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c58); } } } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c59(s1); } s0 = s1; return s0; } function peg$parsehexDigit() { var s0; if (peg$c60.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } return s0; } function peg$parse_() { var s0, s1, s2; peg$silentFails++; s0 = peg$currPos; s1 = []; s2 = peg$parsewhitespace(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsewhitespace(); } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c63(s1); } s0 = s1; peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c62); } } return s0; } function peg$parsewhitespace() { var s0; if (peg$c64.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c65); } } return s0; } peg$result = peg$startRuleFunction(); if (peg$result !== peg$FAILED && peg$currPos === input.length) { return peg$result; } else { if (peg$result !== peg$FAILED && peg$currPos < input.length) { peg$fail({ type: "end", description: "end of input" }); } throw peg$buildException( null, peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) ); } } return { SyntaxError: peg$SyntaxError, parse: peg$parse }; })(); },{}],2:[function(require,module,exports){ /** @file messageformat.js - ICU PluralFormat + SelectFormat for JavaScript * * @author Alex Sexton - @SlexAxton, Eemeli Aro * @version 0.3.1 * @copyright 2012-2016 Alex Sexton, Eemeli Aro, and Contributors * @license To use or fork, MIT. To contribute back, Dojo CLA */ /** Utility function for quoting an Object's key value iff required * * @private */ function propname(key, obj) { /* Quote the key if it contains invalid characters or is an * ECMAScript 3rd Edition reserved word. */ if (/^[A-Z_$][0-9A-Z_$]*$/i.test(key) && ['break', 'continue', 'delete', 'else', 'for', 'function', 'if', 'in', 'new', 'return', 'this', 'typeof', 'var', 'void', 'while', 'with', 'case', 'catch', 'default', 'do', 'finally', 'instanceof', 'switch', 'throw', 'try'].indexOf(key) < 0) { return obj ? obj + '.' + key : key; } else { var jkey = JSON.stringify(key); return obj ? obj + '[' + jkey + ']' : jkey; } } /** Utility formatter function for enforcing Bidi Structured Text by using UCC * * @private */ function bidiMarkText(text, locale) { function isLocaleRTL(locale) { /* list inlined from data extracted from CLDR v27 & v28 * to verify/recreate, use the following: * git clone https://github.com/unicode-cldr/cldr-misc-full.git * cd cldr-misc-full/main/ * grep characterOrder -r . | tr '"/' '\t' | cut -f2,6 | grep -C4 right-to-left */ var rtlLanguages = ['ar', 'ckb', 'fa', 'he', 'ks($|[^bfh])', 'lrc', 'mzn', 'pa-Arab', 'ps', 'ug', 'ur', 'uz-Arab', 'yi']; return new RegExp('^' + rtlLanguages.join('|^')).test(locale); } var mark = JSON.stringify(isLocaleRTL(locale) ? '\u200F' : '\u200E'); return mark + ' + ' + text + ' + ' + mark; } /** Create a new message formatter * * @class * @param {string|string[]} [locale="en"] - The locale to use, with fallbacks * @param {function} [pluralFunc] - Optional custom pluralization function * @param {function[]} [formatters] - Optional custom formatting functions */ function MessageFormat(locale, pluralFunc, formatters) { if (!locale) { this.lc = ['en']; } else if (typeof locale == 'string') { this.lc = []; for (var l = locale; l; l = l.replace(/[-_]?[^-_]*$/, '')) this.lc.push(l); } else { this.lc = locale; } if (!pluralFunc) { if (this.lc.every(function(l){ pluralFunc = MessageFormat.plurals[l]; return !pluralFunc; })) { throw new Error('Plural function for locale `' + this.lc.join(',') + '` not found'); } } this.runtime = new Runtime(this.lc[0], pluralFunc, formatters); } module.exports = MessageFormat; /** Parse an input string to its AST * * Precompiled from `lib/messageformat-parser.pegjs` by * {@link http://pegjs.org/ PEG.js}. Included in MessageFormat object * to enable testing. * * @private */ MessageFormat._parse = require('./messageformat-parser').parse; /** Pluralization functions from * {@link http://github.com/eemeli/make-plural.js make-plural} * * @memberof MessageFormat * @type Object. */ MessageFormat.plurals = require('make-plural/plurals'); /** Default number formatting functions in the style of ICU's * {@link http://icu-project.org/apiref/icu4j/com/ibm/icu/text/MessageFormat.html simpleArg syntax} * implemented using the * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl Intl} * object defined by ECMA-402. * * **Note**: Intl is not defined in default Node until 0.11.15 / 0.12.0, so * earlier versions require a {@link https://www.npmjs.com/package/intl polyfill}. * Therefore {@link MessageFormat.withIntlSupport} needs to be true for these * functions to be available for inclusion in the output. * * @see MessageFormat#setIntlSupport * * @namespace * @memberof MessageFormat * @property {function} number - Represent a number as an integer, percent or currency value * @property {function} date - Represent a date as a full/long/default/short string * @property {function} time - Represent a time as a full/long/default/short string * * @example * var mf = new MessageFormat('en').setIntlSupport(true); * mf.currency = 'EUR'; * var cf = mf.compile('The total is {V,number,currency}.'); * * cf({ V: 5.5 }) * // 'The total is €5.50.' * * @example * var mf = new MessageFormat('en', null, {number: MessageFormat.number}); * mf.currency = 'EUR'; * var cf = mf.compile('The total is {V,number,currency}.'); * * cf({ V: 5.5 }) * // 'The total is €5.50.' */ MessageFormat.formatters = { number: function(self) { return new Function("v,lc,p", "return Intl.NumberFormat(lc,\n" + " p=='integer' ? {maximumFractionDigits:0}\n" + " : p=='percent' ? {style:'percent'}\n" + " : p=='currency' ? {style:'currency', currency:'" + (self.currency || 'USD') + "', minimumFractionDigits:2, maximumFractionDigits:2}\n" + " : {}).format(v)" ); }, date: function(v,lc,p) { var o = {day:'numeric', month:'short', year:'numeric'}; switch (p) { case 'full': o.weekday = 'long'; case 'long': o.month = 'long'; break; case 'short': o.month = 'numeric'; } return (new Date(v)).toLocaleDateString(lc, o) }, time: function(v,lc,p) { var o = {second:'numeric', minute:'numeric', hour:'numeric'}; switch (p) { case 'full': case 'long': o.timeZoneName = 'short'; break; case 'short': delete o.minute; } return (new Date(v)).toLocaleTimeString(lc, o) } }; /** Enable or disable the addition of Unicode control characters to all input * to preserve the integrity of the output when mixing LTR and RTL text. * * @see http://cldr.unicode.org/development/development-process/design-proposals/bidi-handling-of-structured-text * * @memberof MessageFormat * @param {boolean} [enable=true] * @returns {MessageFormat} The MessageFormat instance, to allow for chaining * * @example * // upper case stands for RTL characters, output is shown as rendered * var mf = new MessageFormat('en'); * * mf.compile('{0} >> {1} >> {2}')(['first', 'SECOND', 'THIRD']); * // 'first >> THIRD << SECOND' * * mf.setBiDiSupport(true); * mf.compile('{0} >> {1} >> {2}')(['first', 'SECOND', 'THIRD']); * // 'first >> SECOND >> THIRD' */ MessageFormat.prototype.setBiDiSupport = function(enable) { this.bidiSupport = !!enable || (typeof enable == 'undefined'); return this; }; /** Enable or disable support for the default formatters, which require the * `Intl` object. Note that this can't be autodetected, as the environment * in which the formatted text is compiled into Javascript functions is not * necessarily the same environment in which they will get executed. * * @see MessageFormat.formatters * * @memberof MessageFormat * @param {boolean} [enable=true] * @returns {MessageFormat} The MessageFormat instance, to allow for chaining * * @example * // Intl is not defined in default Node until 0.11.15 / 0.12.0 * var Intl = require('intl'); * var mf = new MessageFormat('en').setIntlSupport(true); * mf.currency = 'EUR'; * * mf.compile('The total is {V,number,currency}.')({ V: 5.5 }); * // 'The total is €5.50.' */ MessageFormat.prototype.setIntlSupport = function(enable) { this.withIntlSupport = !!enable || (typeof enable == 'undefined'); return this; }; /** A set of utility functions that are called by the compiled Javascript * functions, these are included locally in the output of {@link * MessageFormat#compile compile()}. * * @class * @param {string} [locale] - The parsed locale * @param {function} [pluralFunc] - Pluralization function for the locale * @param {function[]} [formatters] - Optional custom formatting functions */ function Runtime(locale, pluralFunc, formatters) { /** Pluralization functions included in compiled output * * @instance * @type Object. */ this.pluralFuncs = {}; this.pluralFuncs[locale] = pluralFunc; /** Custom formatting functions called by `{var, fn[, args]*}` syntax * * For examples, see {@link MessageFormat.formatters} * * @instance * @see MessageFormat.formatters * @type Object. */ this.fmt = {}; if (formatters) for (var f in formatters) { this.fmt[f] = formatters[f]; } } Runtime.prototype = { /** Utility function for `#` in plural rules * * @param {number} value - The value to operate on * @param {number} [offset=0] - An optional offset, set by the surrounding context */ number: function(value, offset) { if (isNaN(value)) throw new Error("'" + value + "' isn't a number."); return value - (offset || 0); }, /** Utility function for `{N, plural|selectordinal, ...}` * * @param {number} value - The key to use to find a pluralization rule * @param {number} offset - An offset to apply to `value` * @param {function} lcfunc - A locale function from `pluralFuncs` * @param {Object.} data - The object from which results are looked up * @param {?boolean} isOrdinal - If true, use ordinal rather than cardinal rules * @returns {string} The result of the pluralization */ plural: function(value, offset, lcfunc, data, isOrdinal) { if ({}.hasOwnProperty.call(data, value)) return data[value](); if (offset) value -= offset; var key = lcfunc(value, isOrdinal); if (key in data) return data[key](); return data.other(); }, /** Utility function for `{N, select, ...}` * * @param {number} value - The key to use to find a selection * @param {Object.} data - The object from which results are looked up * @returns {string} The result of the select statement */ select: function(value, data) { if ({}.hasOwnProperty.call(data, value)) return data[value](); return data.other() }, /** Custom stringifier * * @example * var mf = new MessageFormat('en'); * console.log(mf.runtime.toString()) * > var pluralFuncs = { * > en: function (n, ord) { * > var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, * > n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); * > if (ord) return (n10 == 1 && n100 != 11) ? 'one' * > : (n10 == 2 && n100 != 12) ? 'two' * > : (n10 == 3 && n100 != 13) ? 'few' * > : 'other'; * > return (n == 1 && v0) ? 'one' : 'other'; * > } * > }; * > var fmt = {}; * > var number = function (value, offset) { * > if (isNaN(value)) throw new Error("'" + value + "' isn't a number."); * > return value - (offset || 0); * > }; * > var plural = function (value, offset, lcfunc, data, isOrdinal) { * > if ({}.hasOwnProperty.call(data, value)) return data[value](); * > if (offset) value -= offset; * > var key = lcfunc(value, isOrdinal); * > if (key in data) return data[key](); * > return data.other(); * > }; * > var select = function (value, data) { * > if ({}.hasOwnProperty.call(data, value)) return data[value](); * > return data.other() * > }; */ toString: function () { var _stringify = function(o, level) { if (typeof o != 'object') { var funcStr = o.toString().replace(/^(function )\w*/, '$1'); var indent = /([ \t]*)\S.*$/.exec(funcStr); return indent ? funcStr.replace(new RegExp('^' + indent[1], 'mg'), '') : funcStr; } var s = []; for (var i in o) if (i != 'toString') { if (level == 0) s.push('var ' + i + ' = ' + _stringify(o[i], level + 1) + ';\n'); else s.push(propname(i) + ': ' + _stringify(o[i], level + 1)); } if (level == 0) return s.join(''); if (s.length == 0) return '{}'; var indent = ' '; while (--level) indent += ' '; return '{\n' + s.join(',\n').replace(/^/gm, indent) + '\n}'; }; return _stringify(this, 0); } }; /** Recursively map an AST to its resulting string * * @memberof MessageFormat * @param ast - the Ast node for which the JS code should be generated * @private */ MessageFormat.prototype._precompile = function(ast, data) { data = data || { keys: {}, offset: {} }; var r = [], i, tmp, args = []; switch ( ast.type ) { case 'messageFormatPattern': for ( i = 0; i < ast.statements.length; ++i ) { r.push(this._precompile( ast.statements[i], data )); } tmp = r.join(' + ') || '""'; return data.pf_count ? tmp : 'function(d) { return ' + tmp + '; }'; case 'messageFormatElement': data.pf_count = data.pf_count || 0; if ( ast.output ) { var ret = propname(ast.argumentIndex, 'd'); return this.bidiSupport ? bidiMarkText(ret, this.lc) : ret; } else { data.keys[data.pf_count] = ast.argumentIndex; return this._precompile( ast.elementFormat, data ); } return ''; case 'elementFormat': args = [ propname(data.keys[data.pf_count], 'd') ]; switch (ast.key) { case 'select': args.push(this._precompile(ast.val, data)); return 'select(' + args.join(', ') + ')'; case 'selectordinal': args = args.concat([ 0, propname(this.lc[0], 'pluralFuncs'), this._precompile(ast.val, data), 1 ]); return 'plural(' + args.join(', ') + ')'; case 'plural': data.offset[data.pf_count || 0] = ast.val.offset || 0; args = args.concat([ data.offset[data.pf_count] || 0, propname(this.lc[0], 'pluralFuncs'), this._precompile(ast.val, data) ]); return 'plural(' + args.join(', ') + ')'; default: if (this.withIntlSupport && !(ast.key in this.runtime.fmt) && (ast.key in MessageFormat.formatters)) { tmp = MessageFormat.formatters[ast.key]; this.runtime.fmt[ast.key] = (typeof tmp(this) == 'function') ? tmp(this) : tmp; } args.push(JSON.stringify(this.lc)); if (ast.val && ast.val.length) args.push(JSON.stringify(ast.val.length == 1 ? ast.val[0] : ast.val)); return 'fmt.' + ast.key + '(' + args.join(', ') + ')'; } case 'pluralFormatPattern': case 'selectFormatPattern': data.pf_count = data.pf_count || 0; if (ast.type == 'selectFormatPattern') data.offset[data.pf_count] = 0; var needOther = true; for (i = 0; i < ast.pluralForms.length; ++i) { var key = ast.pluralForms[i].key; if (key === 'other') needOther = false; var data_copy = JSON.parse(JSON.stringify(data)); data_copy.pf_count++; r.push(propname(key) + ': function() { return ' + this._precompile(ast.pluralForms[i].val, data_copy) + ';}'); } if (needOther) throw new Error("No 'other' form found in " + ast.type + " " + data.pf_count); return '{ ' + r.join(', ') + ' }'; case 'string': return JSON.stringify(ast.val || ""); case 'octothorpe': if (!data.pf_count) return '"#"'; args = [ propname(data.keys[data.pf_count-1], 'd') ]; if (data.offset[data.pf_count-1]) args.push(data.offset[data.pf_count-1]); return 'number(' + args.join(', ') + ')'; default: throw new Error( 'Bad AST type: ' + ast.type ); } }; /** Compile messages into an executable function with clean string * representation. * * If `messages` is a single string including ICU MessageFormat declarations, * `opt` is ignored and the returned function takes a single Object parameter * `d` representing each of the input's defined variables. The returned * function will be defined in a local scope that includes all the required * runtime variables. * * If `messages` is a map of keys to strings, or a map of namespace keys to * such key/string maps, the returned function will fill the specified global * with javascript functions matching the structure of the input. In such use, * the result of `compile()` may be serialized using its `toString()` method, * including all required runtime function definitions. If `opt.global` is * null, calling the output function will return the object itself. * * Together, the input parameters should match the following patterns: * ```js * messages = "string" || { key0: "string0", key1: "string1", ... } || { * ns0: { key0: "string0", key1: "string1", ... }, * ns1: { key0: "string0", key1: "string1", ... }, * ... * } * * opt = null || { * locale: null || { * ns0: "lc0" || [ "lc0", ... ], * ns1: "lc1" || [ "lc1", ... ], * ... * }, * global: null || "module.exports" || "exports" || "i18n" || ... * } * ``` * * @memberof MessageFormat * @param {string|Object} * messages - The input message(s) to be compiled, in ICU MessageFormat * @param {Object} [opt={}] - Options controlling output for non-simple intput * @param {Object} [opt.locale] - The locales to use for the messages, with a * structure matching that of `messages` * @param {string} [opt.global=""] - The global variable that the output * function should use, or a null string for none. "exports" and * "module.exports" are recognised as special cases. * @returns {function} The first match found for the given locale(s) * * @example * var mf = new MessageFormat('en'); * var cf = mf.compile('A {TYPE} example.'); * * cf({ TYPE: 'simple' }) * // 'A simple example.' * * cf.toString() * // 'function (d) { return "A " + d.TYPE + " example."; }' * * @example * var fs = require('fs'); * var mf = new MessageFormat('en'); * var msgSet = { * a: 'A {TYPE} example.', * b: 'This has {COUNT, plural, one{one member} other{# members}}.' * }; * var cfSet = mf.compile(msgSet, { global: 'module.exports' }); * var str = cfSet.toString().replace(/^[^{]*{/, '').replace(/}\s*$/, '').trim(); * fs.writeFileSync('messages.js', str); * ... * var messages = require('./messages'); * * messages.a({ TYPE: 'more complex' }) * // 'A more complex example.' * * messages.b({ COUNT: 2 }) * // 'This has 2 members.' * * @example * var mf = new MessageFormat('en'); * mf.runtime.pluralFuncs.fi = MessageFormat.plurals.fi; * mf.compile({ * en: { a: 'A {TYPE} example.', * b: 'This is the {COUNT, selectordinal, one{#st} two{#nd} few{#rd} other{#th}} example.' }, * fi: { a: '{TYPE} esimerkki.', * b: 'Tämä on {COUNT, selectordinal, other{#.}} esimerkki.' } * }, { * locale: { en: 'en', fi: 'fi' }, * global: 'i18n' * })(this); * * i18n.en.b({ COUNT: 3 }) * // 'This is the 3rd example.' * * i18n.fi.b({ COUNT: 3 }) * // 'Tämä on 3. esimerkki.' */ MessageFormat.prototype.compile = function ( messages, opt ) { var r = {}, lc0 = this.lc, compileMsg = function(self, msg) { try { var ast = MessageFormat._parse(msg); return self._precompile(ast); } catch (e) { throw new Error((ast ? 'Precompiler' : 'Parser') + ' error: ' + e.toString()); } }, stringify = function(r, level) { if (!level) level = 0; if (typeof r != 'object') return r; var o = [], indent = ''; for (var i = 0; i < level; ++i) indent += ' '; for (var k in r) o.push('\n' + indent + ' ' + propname(k) + ': ' + stringify(r[k], level + 1)); return '{' + o.join(',') + '\n' + indent + '}'; }; if (typeof messages == 'string') { var f = new Function( 'number, plural, select, pluralFuncs, fmt', 'return ' + compileMsg(this, messages)); return f(this.runtime.number, this.runtime.plural, this.runtime.select, this.runtime.pluralFuncs, this.runtime.fmt); } opt = opt || {}; for (var ns in messages) { if (opt.locale) this.lc = opt.locale[ns] && [].concat(opt.locale[ns]) || lc0; if (typeof messages[ns] == 'string') { try { r[ns] = compileMsg(this, messages[ns]); } catch (e) { e.message = e.message.replace(':', ' with `' + ns + '`:'); throw e; } } else { r[ns] = {}; for (var key in messages[ns]) { try { r[ns][key] = compileMsg(this, messages[ns][key]); } catch (e) { e.message = e.message.replace(':', ' with `' + key + '` in `' + ns + '`:'); throw e; } } } } this.lc = lc0; var s = this.runtime.toString() + '\n'; switch (opt.global || '') { case 'exports': var o = []; for (var k in r) o.push(propname(k, 'exports') + ' = ' + stringify(r[k])); return new Function(s + o.join(';\n')); case 'module.exports': return new Function(s + 'module.exports = ' + stringify(r)); case '': return new Function(s + 'return ' + stringify(r)); default: return new Function('G', s + propname(opt.global, 'G') + ' = ' + stringify(r)); } }; },{"./messageformat-parser":1,"make-plural/plurals":3}],3:[function(require,module,exports){ var _cp = [ function(n, ord) { if (ord) return 'other'; return 'other'; }, function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : 'other'; }, function(n, ord) { if (ord) return 'other'; return ((n == 0 || n == 1)) ? 'one' : 'other'; }, function(n, ord) { var s = String(n).split('.'), v0 = !s[1]; if (ord) return 'other'; return (n == 1 && v0) ? 'one' : 'other'; } ]; (function (root, plurals) { if (typeof define === 'function' && define.amd) { define(plurals); } else if (typeof exports === 'object') { module.exports = plurals; } else { root.plurals = plurals; } }(this, { af: _cp[1], ak: _cp[2], am: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, ar: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n100 = t0 && s[0].slice(-2); if (ord) return 'other'; return (n == 0) ? 'zero' : (n == 1) ? 'one' : (n == 2) ? 'two' : ((n100 >= 3 && n100 <= 10)) ? 'few' : ((n100 >= 11 && n100 <= 99)) ? 'many' : 'other'; }, as: function(n, ord) { if (ord) return ((n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10)) ? 'one' : ((n == 2 || n == 3)) ? 'two' : (n == 4) ? 'few' : (n == 6) ? 'many' : 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, asa: _cp[1], ast: _cp[3], az: function(n, ord) { var s = String(n).split('.'), i = s[0], i10 = i.slice(-1), i100 = i.slice(-2), i1000 = i.slice(-3); if (ord) return ((i10 == 1 || i10 == 2 || i10 == 5 || i10 == 7 || i10 == 8) || (i100 == 20 || i100 == 50 || i100 == 70 || i100 == 80)) ? 'one' : ((i10 == 3 || i10 == 4) || (i1000 == 100 || i1000 == 200 || i1000 == 300 || i1000 == 400 || i1000 == 500 || i1000 == 600 || i1000 == 700 || i1000 == 800 || i1000 == 900)) ? 'few' : (i == 0 || i10 == 6 || (i100 == 40 || i100 == 60 || i100 == 90)) ? 'many' : 'other'; return (n == 1) ? 'one' : 'other'; }, be: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); if (ord) return ((n10 == 2 || n10 == 3) && n100 != 12 && n100 != 13) ? 'few' : 'other'; return (n10 == 1 && n100 != 11) ? 'one' : ((n10 >= 2 && n10 <= 4) && (n100 < 12 || n100 > 14)) ? 'few' : (t0 && n10 == 0 || (n10 >= 5 && n10 <= 9) || (n100 >= 11 && n100 <= 14)) ? 'many' : 'other'; }, bem: _cp[1], bez: _cp[1], bg: _cp[1], bh: _cp[2], bm: _cp[0], bn: function(n, ord) { if (ord) return ((n == 1 || n == 5 || n == 7 || n == 8 || n == 9 || n == 10)) ? 'one' : ((n == 2 || n == 3)) ? 'two' : (n == 4) ? 'few' : (n == 6) ? 'many' : 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, bo: _cp[0], br: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2), n1000000 = t0 && s[0].slice(-6); if (ord) return 'other'; return (n10 == 1 && n100 != 11 && n100 != 71 && n100 != 91) ? 'one' : (n10 == 2 && n100 != 12 && n100 != 72 && n100 != 92) ? 'two' : (((n10 == 3 || n10 == 4) || n10 == 9) && (n100 < 10 || n100 > 19) && (n100 < 70 || n100 > 79) && (n100 < 90 || n100 > 99)) ? 'few' : (n != 0 && t0 && n1000000 == 0) ? 'many' : 'other'; }, brx: _cp[1], bs: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2), f10 = f.slice(-1), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14) || (f10 >= 2 && f10 <= 4) && (f100 < 12 || f100 > 14)) ? 'few' : 'other'; }, ca: function(n, ord) { var s = String(n).split('.'), v0 = !s[1]; if (ord) return ((n == 1 || n == 3)) ? 'one' : (n == 2) ? 'two' : (n == 4) ? 'few' : 'other'; return (n == 1 && v0) ? 'one' : 'other'; }, ce: _cp[1], cgg: _cp[1], chr: _cp[1], ckb: _cp[1], cs: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1]; if (ord) return 'other'; return (n == 1 && v0) ? 'one' : ((i >= 2 && i <= 4) && v0) ? 'few' : (!v0) ? 'many' : 'other'; }, cy: function(n, ord) { if (ord) return ((n == 0 || n == 7 || n == 8 || n == 9)) ? 'zero' : (n == 1) ? 'one' : (n == 2) ? 'two' : ((n == 3 || n == 4)) ? 'few' : ((n == 5 || n == 6)) ? 'many' : 'other'; return (n == 0) ? 'zero' : (n == 1) ? 'one' : (n == 2) ? 'two' : (n == 3) ? 'few' : (n == 6) ? 'many' : 'other'; }, da: function(n, ord) { var s = String(n).split('.'), i = s[0], t0 = Number(s[0]) == n; if (ord) return 'other'; return (n == 1 || !t0 && (i == 0 || i == 1)) ? 'one' : 'other'; }, de: _cp[3], dsb: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i100 = i.slice(-2), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i100 == 1 || f100 == 1) ? 'one' : (v0 && i100 == 2 || f100 == 2) ? 'two' : (v0 && (i100 == 3 || i100 == 4) || (f100 == 3 || f100 == 4)) ? 'few' : 'other'; }, dv: _cp[1], dz: _cp[0], ee: _cp[1], el: _cp[1], en: function(n, ord) { var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); if (ord) return (n10 == 1 && n100 != 11) ? 'one' : (n10 == 2 && n100 != 12) ? 'two' : (n10 == 3 && n100 != 13) ? 'few' : 'other'; return (n == 1 && v0) ? 'one' : 'other'; }, eo: _cp[1], es: _cp[1], et: _cp[3], eu: _cp[1], fa: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, ff: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n < 2) ? 'one' : 'other'; }, fi: _cp[3], fil: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), f10 = f.slice(-1); if (ord) return (n == 1) ? 'one' : 'other'; return (v0 && (i == 1 || i == 2 || i == 3) || v0 && i10 != 4 && i10 != 6 && i10 != 9 || !v0 && f10 != 4 && f10 != 6 && f10 != 9) ? 'one' : 'other'; }, fo: _cp[1], fr: function(n, ord) { if (ord) return (n == 1) ? 'one' : 'other'; return (n >= 0 && n < 2) ? 'one' : 'other'; }, fur: _cp[1], fy: _cp[3], ga: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return (n == 1) ? 'one' : 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : ((t0 && n >= 3 && n <= 6)) ? 'few' : ((t0 && n >= 7 && n <= 10)) ? 'many' : 'other'; }, gd: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return 'other'; return ((n == 1 || n == 11)) ? 'one' : ((n == 2 || n == 12)) ? 'two' : (((t0 && n >= 3 && n <= 10) || (t0 && n >= 13 && n <= 19))) ? 'few' : 'other'; }, gl: _cp[3], gsw: _cp[1], gu: function(n, ord) { if (ord) return (n == 1) ? 'one' : ((n == 2 || n == 3)) ? 'two' : (n == 4) ? 'few' : (n == 6) ? 'many' : 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, guw: _cp[2], gv: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1) ? 'one' : (v0 && i10 == 2) ? 'two' : (v0 && (i100 == 0 || i100 == 20 || i100 == 40 || i100 == 60 || i100 == 80)) ? 'few' : (!v0) ? 'many' : 'other'; }, ha: _cp[1], haw: _cp[1], he: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1); if (ord) return 'other'; return (n == 1 && v0) ? 'one' : (i == 2 && v0) ? 'two' : (v0 && (n < 0 || n > 10) && t0 && n10 == 0) ? 'many' : 'other'; }, hi: function(n, ord) { if (ord) return (n == 1) ? 'one' : ((n == 2 || n == 3)) ? 'two' : (n == 4) ? 'few' : (n == 6) ? 'many' : 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, hr: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2), f10 = f.slice(-1), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14) || (f10 >= 2 && f10 <= 4) && (f100 < 12 || f100 > 14)) ? 'few' : 'other'; }, hsb: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i100 = i.slice(-2), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i100 == 1 || f100 == 1) ? 'one' : (v0 && i100 == 2 || f100 == 2) ? 'two' : (v0 && (i100 == 3 || i100 == 4) || (f100 == 3 || f100 == 4)) ? 'few' : 'other'; }, hu: function(n, ord) { if (ord) return ((n == 1 || n == 5)) ? 'one' : 'other'; return (n == 1) ? 'one' : 'other'; }, hy: function(n, ord) { if (ord) return (n == 1) ? 'one' : 'other'; return (n >= 0 && n < 2) ? 'one' : 'other'; }, id: _cp[0], ig: _cp[0], ii: _cp[0], "in": _cp[0], is: function(n, ord) { var s = String(n).split('.'), i = s[0], t0 = Number(s[0]) == n, i10 = i.slice(-1), i100 = i.slice(-2); if (ord) return 'other'; return (t0 && i10 == 1 && i100 != 11 || !t0) ? 'one' : 'other'; }, it: function(n, ord) { var s = String(n).split('.'), v0 = !s[1]; if (ord) return ((n == 11 || n == 8 || n == 80 || n == 800)) ? 'many' : 'other'; return (n == 1 && v0) ? 'one' : 'other'; }, iu: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, iw: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1); if (ord) return 'other'; return (n == 1 && v0) ? 'one' : (i == 2 && v0) ? 'two' : (v0 && (n < 0 || n > 10) && t0 && n10 == 0) ? 'many' : 'other'; }, ja: _cp[0], jbo: _cp[0], jgo: _cp[1], ji: _cp[3], jmc: _cp[1], jv: _cp[0], jw: _cp[0], ka: function(n, ord) { var s = String(n).split('.'), i = s[0], i100 = i.slice(-2); if (ord) return (i == 1) ? 'one' : (i == 0 || ((i100 >= 2 && i100 <= 20) || i100 == 40 || i100 == 60 || i100 == 80)) ? 'many' : 'other'; return (n == 1) ? 'one' : 'other'; }, kab: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n < 2) ? 'one' : 'other'; }, kaj: _cp[1], kcg: _cp[1], kde: _cp[0], kea: _cp[0], kk: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1); if (ord) return (n10 == 6 || n10 == 9 || t0 && n10 == 0 && n != 0) ? 'many' : 'other'; return (n == 1) ? 'one' : 'other'; }, kkj: _cp[1], kl: _cp[1], km: _cp[0], kn: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, ko: _cp[0], ks: _cp[1], ksb: _cp[1], ksh: function(n, ord) { if (ord) return 'other'; return (n == 0) ? 'zero' : (n == 1) ? 'one' : 'other'; }, ku: _cp[1], kw: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, ky: _cp[1], lag: function(n, ord) { var s = String(n).split('.'), i = s[0]; if (ord) return 'other'; return (n == 0) ? 'zero' : ((i == 0 || i == 1) && n != 0) ? 'one' : 'other'; }, lb: _cp[1], lg: _cp[1], lkt: _cp[0], ln: _cp[2], lo: function(n, ord) { if (ord) return (n == 1) ? 'one' : 'other'; return 'other'; }, lt: function(n, ord) { var s = String(n).split('.'), f = s[1] || '', t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); if (ord) return 'other'; return (n10 == 1 && (n100 < 11 || n100 > 19)) ? 'one' : ((n10 >= 2 && n10 <= 9) && (n100 < 11 || n100 > 19)) ? 'few' : (f != 0) ? 'many' : 'other'; }, lv: function(n, ord) { var s = String(n).split('.'), f = s[1] || '', v = f.length, t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2), f100 = f.slice(-2), f10 = f.slice(-1); if (ord) return 'other'; return (t0 && n10 == 0 || (n100 >= 11 && n100 <= 19) || v == 2 && (f100 >= 11 && f100 <= 19)) ? 'zero' : (n10 == 1 && n100 != 11 || v == 2 && f10 == 1 && f100 != 11 || v != 2 && f10 == 1) ? 'one' : 'other'; }, mas: _cp[1], mg: _cp[2], mgo: _cp[1], mk: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2), f10 = f.slice(-1); if (ord) return (i10 == 1 && i100 != 11) ? 'one' : (i10 == 2 && i100 != 12) ? 'two' : ((i10 == 7 || i10 == 8) && i100 != 17 && i100 != 18) ? 'many' : 'other'; return (v0 && i10 == 1 || f10 == 1) ? 'one' : 'other'; }, ml: _cp[1], mn: _cp[1], mo: function(n, ord) { var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, n100 = t0 && s[0].slice(-2); if (ord) return (n == 1) ? 'one' : 'other'; return (n == 1 && v0) ? 'one' : (!v0 || n == 0 || n != 1 && (n100 >= 1 && n100 <= 19)) ? 'few' : 'other'; }, mr: function(n, ord) { if (ord) return (n == 1) ? 'one' : ((n == 2 || n == 3)) ? 'two' : (n == 4) ? 'few' : 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; }, ms: function(n, ord) { if (ord) return (n == 1) ? 'one' : 'other'; return 'other'; }, mt: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n100 = t0 && s[0].slice(-2); if (ord) return 'other'; return (n == 1) ? 'one' : (n == 0 || (n100 >= 2 && n100 <= 10)) ? 'few' : ((n100 >= 11 && n100 <= 19)) ? 'many' : 'other'; }, my: _cp[0], nah: _cp[1], naq: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, nb: _cp[1], nd: _cp[1], ne: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return ((t0 && n >= 1 && n <= 4)) ? 'one' : 'other'; return (n == 1) ? 'one' : 'other'; }, nl: _cp[3], nn: _cp[1], nnh: _cp[1], no: _cp[1], nqo: _cp[0], nr: _cp[1], nso: _cp[2], ny: _cp[1], nyn: _cp[1], om: _cp[1], or: _cp[1], os: _cp[1], pa: _cp[2], pap: _cp[1], pl: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2); if (ord) return 'other'; return (n == 1 && v0) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14)) ? 'few' : (v0 && i != 1 && (i10 == 0 || i10 == 1) || v0 && (i10 >= 5 && i10 <= 9) || v0 && (i100 >= 12 && i100 <= 14)) ? 'many' : 'other'; }, prg: function(n, ord) { var s = String(n).split('.'), f = s[1] || '', v = f.length, t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2), f100 = f.slice(-2), f10 = f.slice(-1); if (ord) return 'other'; return (t0 && n10 == 0 || (n100 >= 11 && n100 <= 19) || v == 2 && (f100 >= 11 && f100 <= 19)) ? 'zero' : (n10 == 1 && n100 != 11 || v == 2 && f10 == 1 && f100 != 11 || v != 2 && f10 == 1) ? 'one' : 'other'; }, ps: _cp[1], pt: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return 'other'; return ((t0 && n >= 0 && n <= 2) && n != 2) ? 'one' : 'other'; }, "pt-PT": _cp[3], rm: _cp[1], ro: function(n, ord) { var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, n100 = t0 && s[0].slice(-2); if (ord) return (n == 1) ? 'one' : 'other'; return (n == 1 && v0) ? 'one' : (!v0 || n == 0 || n != 1 && (n100 >= 1 && n100 <= 19)) ? 'few' : 'other'; }, rof: _cp[1], root: _cp[0], ru: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1 && i100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14)) ? 'few' : (v0 && i10 == 0 || v0 && (i10 >= 5 && i10 <= 9) || v0 && (i100 >= 11 && i100 <= 14)) ? 'many' : 'other'; }, rwk: _cp[1], sah: _cp[0], saq: _cp[1], sdh: _cp[1], se: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, seh: _cp[1], ses: _cp[0], sg: _cp[0], sh: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2), f10 = f.slice(-1), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14) || (f10 >= 2 && f10 <= 4) && (f100 < 12 || f100 > 14)) ? 'few' : 'other'; }, shi: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return 'other'; return (n >= 0 && n <= 1) ? 'one' : ((t0 && n >= 2 && n <= 10)) ? 'few' : 'other'; }, si: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || ''; if (ord) return 'other'; return ((n == 0 || n == 1) || i == 0 && f == 1) ? 'one' : 'other'; }, sk: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1]; if (ord) return 'other'; return (n == 1 && v0) ? 'one' : ((i >= 2 && i <= 4) && v0) ? 'few' : (!v0) ? 'many' : 'other'; }, sl: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], i100 = i.slice(-2); if (ord) return 'other'; return (v0 && i100 == 1) ? 'one' : (v0 && i100 == 2) ? 'two' : (v0 && (i100 == 3 || i100 == 4) || !v0) ? 'few' : 'other'; }, sma: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, smi: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, smj: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, smn: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, sms: function(n, ord) { if (ord) return 'other'; return (n == 1) ? 'one' : (n == 2) ? 'two' : 'other'; }, sn: _cp[1], so: _cp[1], sq: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); if (ord) return (n == 1) ? 'one' : (n10 == 4 && n100 != 14) ? 'many' : 'other'; return (n == 1) ? 'one' : 'other'; }, sr: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), i100 = i.slice(-2), f10 = f.slice(-1), f100 = f.slice(-2); if (ord) return 'other'; return (v0 && i10 == 1 && i100 != 11 || f10 == 1 && f100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14) || (f10 >= 2 && f10 <= 4) && (f100 < 12 || f100 > 14)) ? 'few' : 'other'; }, ss: _cp[1], ssy: _cp[1], st: _cp[1], sv: function(n, ord) { var s = String(n).split('.'), v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2); if (ord) return ((n10 == 1 || n10 == 2) && n100 != 11 && n100 != 12) ? 'one' : 'other'; return (n == 1 && v0) ? 'one' : 'other'; }, sw: _cp[3], syr: _cp[1], ta: _cp[1], te: _cp[1], teo: _cp[1], th: _cp[0], ti: _cp[2], tig: _cp[1], tk: _cp[1], tl: function(n, ord) { var s = String(n).split('.'), i = s[0], f = s[1] || '', v0 = !s[1], i10 = i.slice(-1), f10 = f.slice(-1); if (ord) return (n == 1) ? 'one' : 'other'; return (v0 && (i == 1 || i == 2 || i == 3) || v0 && i10 != 4 && i10 != 6 && i10 != 9 || !v0 && f10 != 4 && f10 != 6 && f10 != 9) ? 'one' : 'other'; }, tn: _cp[1], to: _cp[0], tr: _cp[1], ts: _cp[1], tzm: function(n, ord) { var s = String(n).split('.'), t0 = Number(s[0]) == n; if (ord) return 'other'; return ((n == 0 || n == 1) || (t0 && n >= 11 && n <= 99)) ? 'one' : 'other'; }, ug: _cp[1], uk: function(n, ord) { var s = String(n).split('.'), i = s[0], v0 = !s[1], t0 = Number(s[0]) == n, n10 = t0 && s[0].slice(-1), n100 = t0 && s[0].slice(-2), i10 = i.slice(-1), i100 = i.slice(-2); if (ord) return (n10 == 3 && n100 != 13) ? 'few' : 'other'; return (v0 && i10 == 1 && i100 != 11) ? 'one' : (v0 && (i10 >= 2 && i10 <= 4) && (i100 < 12 || i100 > 14)) ? 'few' : (v0 && i10 == 0 || v0 && (i10 >= 5 && i10 <= 9) || v0 && (i100 >= 11 && i100 <= 14)) ? 'many' : 'other'; }, ur: _cp[3], uz: _cp[1], ve: _cp[1], vi: function(n, ord) { if (ord) return (n == 1) ? 'one' : 'other'; return 'other'; }, vo: _cp[1], vun: _cp[1], wa: _cp[2], wae: _cp[1], wo: _cp[0], xh: _cp[1], xog: _cp[1], yi: _cp[3], yo: _cp[0], zh: _cp[0], zu: function(n, ord) { if (ord) return 'other'; return (n >= 0 && n <= 1) ? 'one' : 'other'; } })); },{}]},{},[2])(2) });