From 015d6e9204c2fee3a5c0ba49c9555b726ec47aab Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 9 Apr 2015 15:04:28 +0100 Subject: [PATCH] Use localised strings keys in variable substitution. #8 --- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 6502f274..f76aa841 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -678,15 +678,25 @@ namespace Fungus foreach (Match match in results) { string key = match.Value.Substring(2, match.Value.Length - 3); + + // Look for matching variable first foreach (Variable variable in variables) { if (variable.key == key) { string value = variable.ToString(); subbedText = subbedText.Replace(match.Value, value); - break; + return subbedText; } } + + // Next look for matching localized string + string localizedString = Localization.GetLocalizedString(key); + if (localizedString != null) + { + subbedText = subbedText.Replace(match.Value, localizedString); + return subbedText; + } } return subbedText;