Exemple #1
0
            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);
            }
Exemple #2
0
                internal void ConsumeCurrencyPluralsEntry(ResourceKey key, ResourceValue value)
                {
                    Debug.Assert(pluralsData != null);
                    IResourceTable 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();
                        }
                    }
                }
Exemple #3
0
                /// <summary>
                ///  CurrencyPlurals{
                ///      BYB{
                ///          one{"Belarusian new rouble (1994–1999)"}
                ///          other{"Belarusian new roubles (1994–1999)"}
                ///      }
                ///      ...
                ///  }
                /// </summary>
                internal void ConsumeCurrencyPluralsTable(ResourceKey key, ResourceValue value)
                {
                    // The full CurrencyPlurals table is consumed for parsing only.
                    Debug.Assert(parsingData != null);
                    IResourceTable table = value.GetTable();

                    for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
                    {
                        string         isoCode      = key.ToString();
                        IResourceTable 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;
                        }
                    }
                }