Example #1
0
        /// <summary>
        /// Return the string necessary for grammatically correct pluralization of the given resource ID for the given quantity.
        /// </summary>
        /// <returns>Localized string.</returns>
        /// <param name="id">Plurals resource ID.</param>
        /// <param name="quantity">Quantity.</param>
        public static string GetQuantityString(R.sections.AboutDialog.plurals id, double quantity)
        {
            UnityTranslationInternal.Translator.LoadSection(R.sections.SectionID.AboutDialog, false);

            string[] pluralsValues;
            UnityTranslationInternal.PluralsQuantity pluralsQuantity;

            if (
                UnityTranslationInternal.Translator.tokens[(int)R.sections.SectionID.AboutDialog + 1].selectedLanguage != null
                &&
                UnityTranslationInternal.Translator.tokens[(int)R.sections.SectionID.AboutDialog + 1].selectedLanguage.pluralsValues[(int)id] != null
                )
            {
                pluralsValues   = UnityTranslationInternal.Translator.tokens[(int)R.sections.SectionID.AboutDialog + 1].selectedLanguage.pluralsValues[(int)id];
                pluralsQuantity = UnityTranslationInternal.PluralsRules.pluralsFunctions[(int)UnityTranslationInternal.Translator.language](quantity);
            }
            else
            {
                pluralsValues   = UnityTranslationInternal.Translator.tokens[(int)R.sections.SectionID.AboutDialog + 1].defaultLanguage.pluralsValues[(int)id];
                pluralsQuantity = UnityTranslationInternal.PluralsRules.pluralsFunctions[0](quantity);
            }

            for (int i = (int)pluralsQuantity; i < (int)UnityTranslationInternal.PluralsQuantity.Count; ++i)
            {
                if (pluralsValues[i] != null)
                {
                    return(pluralsValues[i]);
                }
            }

            for (int i = (int)pluralsQuantity - 1; i >= 0; --i)
            {
                if (pluralsValues[i] != null)
                {
                    return(pluralsValues[i]);
                }
            }

            return("");
        }
Example #2
0
 /// <summary>
 /// Formats the string necessary for grammatically correct pluralization of the given resource ID for the given quantity, using the given arguments.
 /// </summary>
 /// <returns>Localized string.</returns>
 /// <param name="id">Plurals resource ID.</param>
 /// <param name="quantity">Quantity.</param>
 /// <param name="formatArgs">Format arguments.</param>
 public static string GetQuantityString(R.sections.AboutDialog.plurals id, double quantity, params object[] formatArgs)
 {
     return(string.Format(GetQuantityString(id, quantity), formatArgs));
 }