You may at times have a need to show variable text, such as "You earned [xpEarned] XP and [goldEarned] coins".
However, the catch is that different languages have different syntax. So it's not just a matter of translating "You earned" + "XP and" + "coins". Instead:
1. In your Text Table asset, use {0} as a placeholder for xpEarned and {1} as a placeholder for goldEarned:
2. In C#, use DialogueManager.GetLocalizedText() to get the localized value of the Text Table field:
Code: Select all
string s = DialogueManager.GetLocalizedText("Earned");
Code: Select all
s = string.Format(s, xpEarned, goldEarned);
Code: Select all
DialogueManager.ShowAlert(s);
See also: How To: Handle Player Gender In Dialogue Text