Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

PluralRules.RestoreDefault

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static void RestoreDefault();

Description

Restores the built-in pluralization rule for every language.

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

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 } }