public bool TryGetPluralizer(string name, out Pluralizer pluralizer) { if (_overlay.TryGetPluralizer(name, out pluralizer)) { return(true); } return(_defaults.TryGetPluralizer(name, out pluralizer)); }
public bool TryGetPluralizer(string name, out Pluralizer pluralizer) { foreach (var tagName in GetMatchingLocaleTags(name.Replace("-", "_"))) { if (_pluralizers.TryGetPluralizer(tagName, out pluralizer)) { return(true); } } pluralizer = null; return(false); }
internal string Pluralize(string locale, ParsedArguments arguments, double n, double offset) { Pluralizer pluralizer; if (!Pluralizers.TryGetPluralizer(locale, out pluralizer)) { pluralizer = DefaultPluralizer; } var pluralForm = pluralizer(n - offset); KeyedBlock other = null; foreach (var keyedBlock in arguments.KeyedBlocks) { if (keyedBlock.Key == OtherKey) { other = keyedBlock; } if (keyedBlock.Key.StartsWith("=")) { var numberLiteral = Convert.ToDouble(keyedBlock.Key.Substring(1)); // ReSharper disable once CompareOfFloatsByEqualityOperator if (numberLiteral == n) { return(keyedBlock.BlockText); } } if (keyedBlock.Key == pluralForm) { return(keyedBlock.BlockText); } } if (other == null) { throw new MessageFormatterException("'other' option not found in pattern."); } return(other.BlockText); }