示例#1
0
            public override void Put(UResource.Key key, UResource.Value value, bool noFallback)
            {
                UResource.ITable contextsTable = value.GetTable();
                for (int i = 0; contextsTable.GetKeyAndValue(i, key, value); ++i)
                {
                    CapitalizationContextUsage usage;
                    if (!contextUsageTypeMap.TryGetValue(key.ToString(), out usage))
                    {
                        continue;
                    }


                    int[] intVector = value.GetInt32Vector();
                    if (intVector.Length < 2)
                    {
                        continue;
                    }

                    int titlecaseInt = (outerInstance.capitalization == DisplayContext.CapitalizationForUIListOrMenu)
                            ? intVector[0] : intVector[1];
                    if (titlecaseInt == 0)
                    {
                        continue;
                    }

                    outerInstance.capitalizationUsage[(int)usage] = true;
                    hasCapitalizationUsage = true;
                }
            }
 /// <summary>
 ///  Currencies%variant{
 ///      TRY{"TL"}
 ///  }
 /// </summary>
 internal void ConsumeCurrenciesVariantTable(UResource.Key key, UResource.Value value)
 {
     // Note: This data is used for parsing but not formatting.
     Debug.Assert(parsingData != null);
     UResource.ITable table = value.GetTable();
     for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
     {
         string isoCode = key.ToString();
         parsingData.symbolToIsoCode[value.GetString()] = isoCode;
     }
 }
 /// <summary>
 ///  CurrencyUnitPatterns{
 ///      other{"{0} {1}"}
 ///      ...
 ///  }
 /// </summary>
 internal void ConsumeCurrencyUnitPatternsTable(UResource.Key key, UResource.Value value)
 {
     Debug.Assert(unitPatterns != null);
     UResource.ITable table = value.GetTable();
     for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
     {
         String pluralKeyword = key.ToString();
         if (unitPatterns.Get(pluralKeyword) == null)
         {
             unitPatterns[pluralKeyword] = value.GetString();
         }
     }
 }
                /// <summary>
                ///  currencySpacing{
                ///      afterCurrency{
                ///          currencyMatch{"[:^S:]"}
                ///          insertBetween{" "}
                ///          surroundingMatch{"[:digit:]"}
                ///      }
                ///      beforeCurrency{
                ///          currencyMatch{"[:^S:]"}
                ///          insertBetween{" "}
                ///          surroundingMatch{"[:digit:]"}
                ///      }
                ///  }
                /// </summary>
                internal void ConsumeCurrencySpacingTable(UResource.Key key, UResource.Value value)
                {
                    Debug.Assert(spacingInfo != null);
                    UResource.ITable spacingTypesTable = value.GetTable();
                    for (int i = 0; spacingTypesTable.GetKeyAndValue(i, key, value); ++i)
                    {
                        CurrencySpacingInfo.SpacingType type;
                        if (key.ContentEquals("beforeCurrency"))
                        {
                            type = CurrencySpacingInfo.SpacingType.Before;
                            spacingInfo.hasBeforeCurrency = true;
                        }
                        else if (key.ContentEquals("afterCurrency"))
                        {
                            type = CurrencySpacingInfo.SpacingType.After;
                            spacingInfo.hasAfterCurrency = true;
                        }
                        else
                        {
                            continue;
                        }

                        UResource.ITable patternsTable = value.GetTable();
                        for (int j = 0; patternsTable.GetKeyAndValue(j, key, value); ++j)
                        {
                            CurrencySpacingInfo.SpacingPattern pattern;
                            if (key.ContentEquals("currencyMatch"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.CurrencyMatch;
                            }
                            else if (key.ContentEquals("surroundingMatch"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.SurroundingMatch;
                            }
                            else if (key.ContentEquals("insertBetween"))
                            {
                                pattern = CurrencySpacingInfo.SpacingPattern.InsertBetween;
                            }
                            else
                            {
                                continue;
                            }

                            spacingInfo.SetSymbolIfNull(type, pattern, value.GetString());
                        }
                    }
                }
                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();
                        }
                    }
                }
 private void ConsumeTopTable(UResource.Key key, UResource.Value value)
 {
     UResource.ITable table = value.GetTable();
     for (int i = 0; table.GetKeyAndValue(i, key, value); i++)
     {
         if (key.ContentEquals("Currencies"))
         {
             ConsumeCurrenciesTable(key, value);
         }
         else if (key.ContentEquals("Currencies%variant"))
         {
             ConsumeCurrenciesVariantTable(key, value);
         }
         else if (key.ContentEquals("CurrencyPlurals"))
         {
             ConsumeCurrencyPluralsTable(key, value);
         }
     }
 }
                /// <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;
                        }
                    }
                }
                /// <summary>
                ///  Currencies{
                ///      ...
                ///      USD{
                ///          "US$",        => symbol
                ///          "US Dollar",  => display name
                ///      }
                ///      ...
                ///      ESP{
                ///          "₧",                  => symbol
                ///          "pesseta espanyola",  => display name
                ///          {
                ///              "¤ #,##0.00",     => currency-specific pattern
                ///              ",",              => currency-specific grouping separator
                ///              ".",              => currency-specific decimal separator
                ///          }
                ///      }
                ///      ...
                ///  }
                /// </summary>
                internal void ConsumeCurrenciesTable(UResource.Key key, UResource.Value value)
                {
                    // The full Currencies 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();
                        if (value.Type != UResourceBundle.ARRAY)
                        {
                            throw new ICUException("Unexpected data type in Currencies table for " + isoCode);
                        }
                        UResource.IArray array = value.GetArray();

                        parsingData.symbolToIsoCode[isoCode] = isoCode; // Add the ISO code itself as a symbol
                        array.GetValue(0, value);
                        parsingData.symbolToIsoCode[value.GetString()] = isoCode;
                        array.GetValue(1, value);
                        parsingData.nameToIsoCode[value.GetString()] = isoCode;
                    }
                }