/*
Handles conversion of plural forms. Only difference between this and
`pythonToICU` is that this also takes a domain argument, and an optional
source domain argument (i.e. source language code).
773414
function (msg, domain, options) {
        var format = options.poFormat || '';
        var source = options.sourceDomain || 'en';
        if (msg.comments && msg.comments.flag) {
            format = msg.comments.flag;
        }
        var msgids = [msg.msgid, msg.msgid_plural];
        var msgstr = msg.msgstr;

        var icuPluralForms = this.getPluralsForDomain(domain);
        var icuSourcePluralForms = this.getPluralsForDomain(source);
        var icuId = '';
        var icuStr = '';
        
        if (format.match(/python-format/g) !== null) {
            icuId = this.pythonPluralToICU(msgids, icuSourcePluralForms);
            icuStr = this.pythonPluralToICU(msgstr, icuPluralForms);
        }
        else if (format.match(/c-format/g) !== null) {
            icuId = this.pythonPluralToICU(msgids, icuSourcePluralForms);
            icuStr = this.pythonPluralToICU(msgstr, icuPluralForms);
        }

        var icuObject = {'icuId': icuId, 'icuStr': icuStr};
        return icuObject;
    }
88089
def _convert_value(self, value_orig):
        
        import ast
        if value_orig is None:
            return value_orig

        if value_orig.startswith("'") and value_orig.endswith("'"):
            value = value_orig[1:-1]
        else:

            try:
                avalue = ast.parse(value_orig).body[0].value
                if isinstance(avalue, ast.BinOp):
                    # this is probably a string that happens to look like
                    # a binary operation, e.g. '25-3'
                    value = value_orig
                else:
                    value = ast.literal_eval(value_orig)
            except Exception:
                value = self._convert_string(value_orig)

            if isinstance(value, int) and '_' in value_orig:
                value = value_orig

        return value
1155907
public function sp($singular, $plural, $count, $autoTranslate = false) {
		if ((int)$count !== 1) {
			$result = $plural;
		} else {
			$result = $singular;
		}

		if ($autoTranslate) {
			$result = __($result);
		}
		return $result;
	}
695530
function translateObject(language, key, destObj, keysArray, valuesArray) {
	return new Promise(function (resolve, reject) {
		translateService.translate(valuesArray, language, function (err, res) {
			if (err || !res) {
				reject(err);
			} else {
				// Google-translate doesn't return an array if we only send a single string to translate
				res = _.concat(res);
				for (var i = 0; i < keysArray.length; i++) {
					destObj[key][keysArray[i]] = res[i].translatedText;
				}

				resolve(destObj);
			}
		});
	});
}
237525
def get_plural_name(cls):
        
        if not hasattr(cls.Meta, 'plural_name'):
            setattr(
                cls.Meta,
                'plural_name',
                inflection.pluralize(cls.get_name())
            )
        return cls.Meta.plural_name
1347886
function _formatCountable(number, singularStr, pluralStr) {
        return StringUtils.format(number > 1 ? pluralStr : singularStr, number);
    }
1287372
public function dngettext($domain, $original, $plural, $value)
    {
        return \dngettext($domain, $original, $plural, $value);
    }
120186
function ungettext(msgid1, msgid2, n) {
        if (_i18n_locale.locale_name == 'en_DEBUG') return __debug_trans_str(msgid1);
        var id = ''+_i18n_plural(n)+'-'+msgid1;
        var entry = _i18n_catalog[id];
        return entry == undefined ? (n==1 ? msgid1 : msgid2)  : entry;
    }
863547
def preprocess(content):
    

    if six.PY2:
        if not isinstance(content, unicode):
            if isinstance(content, str):
                _content = unicode(content, encoding=sys.stdin.encoding)
            elif isinstance(content, int):
                _content = unicode(content)
        else:
            _content = content
        assert isinstance(_content, unicode)

    elif six.PY3:
        _content = str(content)

    _content = re.sub(r'\r|\t|\n', ' ', _content)
    return _content
1120917
function uk__plural(word, num) {
        var forms = word.split('_');
        return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
    }
219877
function pluralize(word, count, inclusive) {
        var pluralized = count === 1
            ? pluralize.singular(word) : pluralize.plural(word);
        return (inclusive ? count + ' ' : '') + pluralized;
    }
511648
function transpileJavaScriptToPythonAndPHP (args) {

    //-------------------------------------------------------------------------

    // transpile JS → Python 3
    let python3Body = transpileJavaScriptToPython3 (args)

    //-------------------------------------------------------------------------

    // remove await from Python 2 body (transpile Python 3 → Python 2)
    let python2Body = transpilePython3ToPython2 (python3Body)

    //-------------------------------------------------------------------------

    // transpile JS → PHP
    let phpBody = transpileJavaScriptToPHP (args)

    return { python3Body, python2Body, phpBody }
}
484607
@SuppressWarnings("unchecked")
    public <T> T convert(Object source, String syntax, Class<T> toClass) {
        Object result = null;

        // What are we converting form
        Class<?> fromClass = source.getClass();

        // Deal with primitives
        Class<?> targetClass = toClass;
        if (toClass.isPrimitive()) {
            targetClass = primitiveTypeMap.get(toClass);
        }

        // Try to convert with any syntax we have been given
        Converter syntaxConverter = converters.get(makeConverterKey(fromClass, syntax, targetClass));
        if (syntaxConverter != null) {
            try {
                result = syntaxConverter.convert(source, targetClass);
            } catch (Exception e) {
                // Ignore as we may still be able to convert successfully
            }
        }

        // Do we actually need to do any conversion?
        if (result == null && targetClass.isAssignableFrom(fromClass)) {
            result = source;
        }

        // If we were given a syntax and we failed to convert drop back to any mapping
        // that will work from class -> to class
        if (result == null && syntax != null) {
            Converter nullSyntaxConverter = converters.get(makeConverterKey(fromClass, null, targetClass));
            if (nullSyntaxConverter != null) {
                try {
                    result = nullSyntaxConverter.convert(source, targetClass);
                } catch (Exception e) {
                    // Handled at the end of the method
                }
            }
        }

        if (result == null) {
            throw new ConverterException(String.format(
                    "Cannot convert %1$s of class %2$s via syntax %3$s to class %4$s", source, source.getClass(),
                    syntax, toClass));
        }

        // We cannot do the safe thing of doing a .cast as we need to rely on auto-unboxing to deal with primitives!
        return (T)result;
    }
383294
def convert(self, language, *args, **kwargs):
        

        for f in find_pos(language):
            PoToXls(src=f, **kwargs).convert()
696041
function getPluralCategory(value, cases, ngLocalization, locale) {
    var /** @type {?} */ key = "=" + value;
    if (cases.indexOf(key) > -1) {
        return key;
    }
    key = ngLocalization.getPluralCategory(value, locale);
    if (cases.indexOf(key) > -1) {
        return key;
    }
    if (cases.indexOf('other') > -1) {
        return 'other';
    }
    throw new Error("No plural message found for value \"" + value + "\"");
}
677658
function(locale_data, l) {
    if (typeof(this.data) == 'undefined') {
        this.data = { };
    }

    if (!l) {
        l = this.lang;
    }

    if (typeof this.data[l] == 'undefined') {
        this.data[l] = {};
    }

    var domain;

    // suck in every domain defined in the supplied data
    for (domain in locale_data) {
        // skip empty specs (flexibly)
        if ((! locale_data.hasOwnProperty(domain)) || !locale_data[domain]) {
            continue;
        }
        // skip if it has no msgid's
        var has_msgids = false;
        for (var msgid in locale_data[domain]) {
            has_msgids = true;
            break;
        }
        if (! has_msgids) {
            continue;
        }


        // grab shortcut to data
        var data = locale_data[domain];

        // if they specifcy a blank domain, default to "messages"
        if (domain === "") {
            domain = "messages";
        }
        // init the data structure
        this.data[l][domain]      = this.data[l][domain]      || { };
        this.data[l][domain].head = this.data[l][domain].head || { };
        this.data[l][domain].msgs = this.data[l][domain].msgs || { };

        for (var head in data.headers) {
            var h = head.toLowerCase();
            this.data[l][domain].head[h] = data.headers[head];
        }

        for (var key in data.items) {
            var item = data.items[key];
            this.data[l][domain].msgs[item.msgid] = item;
        }
    }

    // build the plural forms function
    for (domain in this.data[l]) {
        if (this.data[l][domain].head['plural-forms'] &&
            this.data[l][domain].head['plural-forms'].length > 0 &&
            typeof(this.data[l][domain].head.plural_func) == 'undefined') {
            // untaint data
            var plural_forms = this.data[l][domain].head['plural-forms'];
            var pf_re = new RegExp('^(\\s*nplurals\\s*=\\s*[0-9]+\\s*;\\s*plural\\s*=\\s*(?:\\s|[-\\?\\|&=!<>+*/%:;a-zA-Z0-9_\\(\\)])+)', 'm');
            if (pf_re.test(plural_forms)) {
                //ex english: "Plural-Forms: nplurals=2; plural=(n != 1);\n"
                //pf = "nplurals=2; plural=(n != 1);";
                //ex russian: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10< =4 && (n%100<10 or n%100>=20) ? 1 : 2)
                //pf = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)";

                var pf = this.data[l][domain].head['plural-forms'];
                if (! /;\s*$/.test(pf)) {
                    pf = pf.concat(';');
                }
                /* We used to use eval, but it seems IE has issues with it.
                 * We now use "new Function", though it carries a slightly
                 * bigger performance hit.
                var code = 'function (n) { var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) }; };';
                this.data[l][domain].head.plural_func = eval("("+code+")");
                */
                var code = 'var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };';
                this.data[l][domain].head.plural_func = new Function("n", code);
            } else {
                throw new Error("Syntax error in language file. Plural-Forms header is invalid ["+plural_forms+"]");
            }

        // default to english plural form
        } else if (typeof(this.data[l][domain].head.plural_func) == 'undefined') {
            this.data[l][domain].head.plural_func = function (n) {
                var p = (n != 1) ? 1 : 0;
                return { 'nplural' : 2, 'plural' : p };
            };
        } // else, plural_func already created
    }

    return;
}
202070
def Plural(format_str):
  
  if format_str.startswith('plural?'):
    i = len('plural?')

    try:
      splitchar = format_str[i]  # Usually a space, but could be something else
      _, plural_val, singular_val = format_str.split(splitchar)
    except IndexError:
      raise Error('plural? must have exactly 2 arguments')

    def Formatter(value):
      plural = False
      if isinstance(value, int) and value > 1:
        plural = True
      if isinstance(value, list) and len(value) > 1:
        plural = True

      if plural:
        return plural_val
      else:
        return singular_val

    return Formatter

  else:
    return None