RestoreDefault()
Restores the built-in pluralization rule for every language.
Read time 1 minuteLast updated 7 days ago
Definition
- Type: Method
- Namespace: Unity.SmartStrings.Utilities
- Assembly: UnityEngine.SmartStringsModule
public static void RestoreDefault()
Remarks
Refills PluralRules.IsoLangToDelegate with only the built-in rules, which discards every rule you added or replaced. A change to PluralRules.IsoLangToDelegate applies to all formatting in the project, so call this method once you no longer need your custom rules, for example at the end of a test that registers one.
Additional Resources: PluralRules.IsoLangToDelegate, PluralRules.GetPluralRule
Examples
using System.Globalization;using Unity.SmartStrings;using Unity.SmartStrings.Utilities;using UnityEngine;public static class CustomPluralRuleExample{ public static void FormatWithCustomRule() { var english = CultureInfo.GetCultureInfo("en"); // Use the first plural word for every count while the custom rule is registered. PluralRules.IsoLangToDelegate["en"] = (value, pluralWordsCount) => 0; try { Debug.Log(Smart.Format(english, "{0} {0:plural:item|items}", 5)); // 5 item } finally { PluralRules.RestoreDefault(); } Debug.Log(Smart.Format(english, "{0} {0:plural:item|items}", 5)); // 5 items }}