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; } } }