예제 #1
0
파일: Catalog.cs 프로젝트: bt-nia/NGettext
 /// <summary>
 /// Initializes a new instance of the <see cref="Catalog"/> class that has no translations
 /// using given culture info and plural rule generated by DefaultPluralRuleGenerator for given culture.
 /// </summary>
 /// <param name="cultureInfo">Culture info.</param>
 public Catalog(CultureInfo cultureInfo)
 {
     this.CultureInfo    = cultureInfo;
     this.FormatProvider = cultureInfo;
     this.Translations   = new Dictionary <string, string[]>();
     this.PluralRule     = (new DefaultPluralRuleGenerator()).CreateRule(cultureInfo);
 }
예제 #2
0
        /// <summary>
        /// </summary>
        /// <param name="filterCriteria"></param>
        /// <returns></returns>
        public virtual IPluralRulesEnumerable Query(PluralRuleInfo filterCriteria)
        {
            if (filterCriteria.Equals(PluralRuleInfo.Empty))
            {
                return(this);
            }

            int c = 0;

            foreach (var rule in this)
            {
                if (filterCriteria.FilterMatch(rule.Info))
                {
                    c++;
                }
            }
            IPluralRule[] result = new IPluralRule[c];

            int i = 0;

            foreach (var rule in this)
            {
                if (filterCriteria.FilterMatch(rule.Info))
                {
                    result[i++] = rule;
                }
            }

            return(new PluralRulesArray(result));
        }
예제 #3
0
 public GettextPluralBuilder(IPluralRule pluralRule)
 {
     _pluralRule = pluralRule;
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseCatalog"/> class that has no translations
 /// using given culture info and given plural rule.
 /// </summary>
 /// <param name="cultureInfo"></param>
 /// <param name="pluralRule"></param>
 protected BaseCatalog(CultureInfo cultureInfo, IPluralRule pluralRule)
 {
     this.Translations = new Dictionary<string, string[]>();
     this.CultureInfo = cultureInfo;
     this.PluralRule = pluralRule;
 }