public override string GetPluralName(string isoCode, string pluralKey) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(pluralKey); string[] pluralsData = FetchPluralsData(isoCode); // See http://unicode.org/reports/tr35/#Currencies, especially the fallback rule. string result = null; if (plural != null) { result = pluralsData[1 + (int)plural]; } if (result == null && fallback) { // First fall back to the "other" plural variant // Note: If plural is already "other", this fallback is benign result = pluralsData[1 + (int)StandardPlural.Other]; } if (result == null && fallback) { // If that fails, fall back to the display name FormattingData formattingData = FetchFormattingData(isoCode); result = formattingData.displayName; } if (result == null && fallback) { // If all else fails, return the ISO code result = isoCode; } return(result); }
internal void ConsumeCurrencyPluralsEntry(UResource.Key key, UResource.Value value) { Debug.Assert(pluralsData != null); UResource.ITable pluralsTable = value.GetTable(); for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString()); if (plural == null) { throw new ICUException("Could not make StandardPlural from keyword " + key); } if (pluralsData[1 + (int)plural] == null) { pluralsData[1 + (int)plural] = value.GetString(); } } }
/// <summary> /// CurrencyPlurals{ /// BYB{ /// one{"Belarusian new rouble (1994–1999)"} /// other{"Belarusian new roubles (1994–1999)"} /// } /// ... /// } /// </summary> internal void ConsumeCurrencyPluralsTable(UResource.Key key, UResource.Value value) { // The full CurrencyPlurals table is consumed for parsing only. Debug.Assert(parsingData != null); UResource.ITable table = value.GetTable(); for (int i = 0; table.GetKeyAndValue(i, key, value); i++) { string isoCode = key.ToString(); UResource.ITable pluralsTable = value.GetTable(); for (int j = 0; pluralsTable.GetKeyAndValue(j, key, value); j++) { StandardPlural?plural = StandardPluralUtil.OrNullFromString(key.ToString()); if (plural == null) { throw new ICUException("Could not make StandardPlural from keyword " + key); } parsingData.nameToIsoCode[value.GetString()] = isoCode; } } }
#pragma warning restore 1591 // TODO markdavis FIX HARD-CODED HACK once we have data from CLDR in the bundles static PluralRulesLoader() { string[][] pluralRangeData = new string[][] { new string[] { "locales", "id ja km ko lo ms my th vi zh" }, new string[] { "other", "other", "other" }, new string[] { "locales", "am bn fr gu hi hy kn mr pa zu" }, new string[] { "one", "one", "one" }, new string[] { "one", "other", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "fa" }, new string[] { "one", "one", "other" }, new string[] { "one", "other", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "ka" }, new string[] { "one", "other", "one" }, new string[] { "other", "one", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "az de el gl hu it kk ky ml mn ne nl pt sq sw ta te tr ug uz" }, new string[] { "one", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "other", "other" }, new string[] { "locales", "af bg ca en es et eu fi nb sv ur" }, new string[] { "one", "other", "other" }, new string[] { "other", "one", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "da fil is" }, new string[] { "one", "one", "one" }, new string[] { "one", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "other", "other" }, new string[] { "locales", "si" }, new string[] { "one", "one", "one" }, new string[] { "one", "other", "other" }, new string[] { "other", "one", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "mk" }, new string[] { "one", "one", "other" }, new string[] { "one", "other", "other" }, new string[] { "other", "one", "other" }, new string[] { "other", "other", "other" }, new string[] { "locales", "lv" }, new string[] { "zero", "zero", "other" }, new string[] { "zero", "one", "one" }, new string[] { "zero", "other", "other" }, new string[] { "one", "zero", "other" }, new string[] { "one", "one", "one" }, new string[] { "one", "other", "other" }, new string[] { "other", "zero", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "other", "other" }, new string[] { "locales", "ro" }, new string[] { "one", "few", "few" }, new string[] { "one", "other", "other" }, new string[] { "few", "one", "few" }, new string[] { "few", "few", "few" }, new string[] { "few", "other", "other" }, new string[] { "other", "few", "few" }, new string[] { "other", "other", "other" }, new string[] { "locales", "hr sr bs" }, new string[] { "one", "one", "one" }, new string[] { "one", "few", "few" }, new string[] { "one", "other", "other" }, new string[] { "few", "one", "one" }, new string[] { "few", "few", "few" }, new string[] { "few", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "few", "few" }, new string[] { "other", "other", "other" }, new string[] { "locales", "sl" }, new string[] { "one", "one", "few" }, new string[] { "one", "two", "two" }, new string[] { "one", "few", "few" }, new string[] { "one", "other", "other" }, new string[] { "two", "one", "few" }, new string[] { "two", "two", "two" }, new string[] { "two", "few", "few" }, new string[] { "two", "other", "other" }, new string[] { "few", "one", "few" }, new string[] { "few", "two", "two" }, new string[] { "few", "few", "few" }, new string[] { "few", "other", "other" }, new string[] { "other", "one", "few" }, new string[] { "other", "two", "two" }, new string[] { "other", "few", "few" }, new string[] { "other", "other", "other" }, new string[] { "locales", "he" }, new string[] { "one", "two", "other" }, new string[] { "one", "many", "many" }, new string[] { "one", "other", "other" }, new string[] { "two", "many", "other" }, new string[] { "two", "other", "other" }, new string[] { "many", "many", "many" }, new string[] { "many", "other", "many" }, new string[] { "other", "one", "other" }, new string[] { "other", "two", "other" }, new string[] { "other", "many", "many" }, new string[] { "other", "other", "other" }, new string[] { "locales", "cs pl sk" }, new string[] { "one", "few", "few" }, new string[] { "one", "many", "many" }, new string[] { "one", "other", "other" }, new string[] { "few", "few", "few" }, new string[] { "few", "many", "many" }, new string[] { "few", "other", "other" }, new string[] { "many", "one", "one" }, new string[] { "many", "few", "few" }, new string[] { "many", "many", "many" }, new string[] { "many", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "few", "few" }, new string[] { "other", "many", "many" }, new string[] { "other", "other", "other" }, new string[] { "locales", "lt ru uk" }, new string[] { "one", "one", "one" }, new string[] { "one", "few", "few" }, new string[] { "one", "many", "many" }, new string[] { "one", "other", "other" }, new string[] { "few", "one", "one" }, new string[] { "few", "few", "few" }, new string[] { "few", "many", "many" }, new string[] { "few", "other", "other" }, new string[] { "many", "one", "one" }, new string[] { "many", "few", "few" }, new string[] { "many", "many", "many" }, new string[] { "many", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "few", "few" }, new string[] { "other", "many", "many" }, new string[] { "other", "other", "other" }, new string[] { "locales", "cy" }, new string[] { "zero", "one", "one" }, new string[] { "zero", "two", "two" }, new string[] { "zero", "few", "few" }, new string[] { "zero", "many", "many" }, new string[] { "zero", "other", "other" }, new string[] { "one", "two", "two" }, new string[] { "one", "few", "few" }, new string[] { "one", "many", "many" }, new string[] { "one", "other", "other" }, new string[] { "two", "few", "few" }, new string[] { "two", "many", "many" }, new string[] { "two", "other", "other" }, new string[] { "few", "many", "many" }, new string[] { "few", "other", "other" }, new string[] { "many", "other", "other" }, new string[] { "other", "one", "one" }, new string[] { "other", "two", "two" }, new string[] { "other", "few", "few" }, new string[] { "other", "many", "many" }, new string[] { "other", "other", "other" }, new string[] { "locales", "ar" }, new string[] { "zero", "one", "zero" }, new string[] { "zero", "two", "zero" }, new string[] { "zero", "few", "few" }, new string[] { "zero", "many", "many" }, new string[] { "zero", "other", "other" }, new string[] { "one", "two", "other" }, new string[] { "one", "few", "few" }, new string[] { "one", "many", "many" }, new string[] { "one", "other", "other" }, new string[] { "two", "few", "few" }, new string[] { "two", "many", "many" }, new string[] { "two", "other", "other" }, new string[] { "few", "few", "few" }, new string[] { "few", "many", "many" }, new string[] { "few", "other", "other" }, new string[] { "many", "few", "few" }, new string[] { "many", "many", "many" }, new string[] { "many", "other", "other" }, new string[] { "other", "one", "other" }, new string[] { "other", "two", "other" }, new string[] { "other", "few", "few" }, new string[] { "other", "many", "many" }, new string[] { "other", "other", "other" }, }; #pragma warning disable 612, 618 PluralRanges pr = null; string[] locales = null; IDictionary <string, PluralRanges> tempLocaleIdToPluralRanges = new Dictionary <string, PluralRanges>(); #pragma warning restore 612, 618 foreach (string[] row in pluralRangeData) { if (row[0].Equals("locales")) { if (pr != null) { #pragma warning disable 612, 618 pr.Freeze(); #pragma warning restore 612, 618 foreach (string locale in locales) { tempLocaleIdToPluralRanges[locale] = pr; } } locales = row[1].Split(' '); #pragma warning disable 612, 618 pr = new PluralRanges(); #pragma warning restore 612, 618 } else { StandardPluralUtil.TryFromString(row[0], out StandardPlural start); StandardPluralUtil.TryFromString(row[1], out StandardPlural end); StandardPluralUtil.TryFromString(row[2], out StandardPlural result); #pragma warning disable 612, 618 pr.Add(start, end, result); #pragma warning restore 612, 618 } } // do last one foreach (string locale in locales) { tempLocaleIdToPluralRanges[locale] = pr; } // now make whole thing immutable localeIdToPluralRanges = tempLocaleIdToPluralRanges.ToUnmodifiableDictionary(); }