Browse Source

Merge pull request #135 from FungusGames/fix-localization-parsing

Fix localization parsing
master
Chris Gregan 9 years ago
parent
commit
259d6c7186
  1. 25
      Assets/Fungus/Narrative/Scripts/Localization.cs
  2. 3
      Assets/Tests/Localisation/CSV/localization_dottest.csv
  3. 8
      Assets/Tests/Localisation/CSV/localization_dottest.csv.meta
  4. 1403
      Assets/Tests/Localisation/LocalisationTests.unity

25
Assets/Fungus/Narrative/Scripts/Localization.cs

@ -58,7 +58,18 @@ namespace Fungus
public virtual void Start()
{
// Build cache of localizeable objects in the scene
CacheLocalizeableObjects();
if (localizationFile != null &&
localizationFile.text.Length > 0)
{
SetActiveLanguage(activeLanguage);
}
}
// Build a cache of all the localizeable objects in the scene
protected virtual void CacheLocalizeableObjects()
{
Component[] components = GameObject.FindObjectsOfType<Component>();
foreach (Component component in components)
{
@ -68,12 +79,6 @@ namespace Fungus
localizeableObjects[localizable.GetStringId()] = localizable;
}
}
if (localizationFile != null &&
localizationFile.text.Length > 0)
{
SetActiveLanguage(activeLanguage);
}
}
/**
@ -379,6 +384,12 @@ namespace Fungus
*/
public virtual bool PopulateTextProperty(string stringId, string newText)
{
// Ensure that all localizeable objects have been cached
if (localizeableObjects.Count == 0)
{
CacheLocalizeableObjects();
}
ILocalizable localizable = null;
localizeableObjects.TryGetValue(stringId, out localizable);
if (localizable != null)

3
Assets/Tests/Localisation/CSV/localization_dottest.csv

@ -0,0 +1,3 @@
Key,Description,Standard,FR
SAY.Flowchart.1.Dr. Character,,English,French
CHARACTER.Dr. Character,Character with a . in the name,Dr. Character
1 Key,Description,Standard,FR
2 SAY.Flowchart.1.Dr. Character,,English,French
3 CHARACTER.Dr. Character,Character with a . in the name,Dr. Character

8
Assets/Tests/Localisation/CSV/localization_dottest.csv.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 78fdd98dfc41844f78e4f9bf7d24b99f
timeCreated: 1440696526
licenseType: Free
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant:

1403
Assets/Tests/Localisation/LocalisationTests.unity

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save