Browse Source

SetActiveLanguage is more generic #8

master
chrisgregan 10 years ago
parent
commit
9e37f19560
  1. 20
      Assets/Fungus/Narrative/Scripts/Localization.cs

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

@ -1,4 +1,10 @@
using UnityEngine; /**
* CSVParser by Ideafixxxer. http://www.codeproject.com/Tips/741941/CSV-Parser-Csharp
* This code is licensed under the CPOL open source license.
* http://www.codeproject.com/info/cpol10.aspx
*/
using UnityEngine;
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEditor; using UnityEditor;
#endif #endif
@ -49,7 +55,7 @@ namespace Fungus
if (localizationFile != null && if (localizationFile != null &&
localizationFile.text.Length > 0) localizationFile.text.Length > 0)
{ {
SetActiveLanguage(activeLanguage, localizationFile.text); SetActiveLanguage(activeLanguage);
} }
} }
@ -289,7 +295,7 @@ namespace Fungus
* Scan a localization CSV file and copies the strings for the specified language code * Scan a localization CSV file and copies the strings for the specified language code
* into the text properties of the appropriate scene objects. * into the text properties of the appropriate scene objects.
*/ */
public virtual void SetActiveLanguage(string languageCode, string csvData) public virtual void SetActiveLanguage(string languageCode)
{ {
if (!Application.isPlaying) if (!Application.isPlaying)
{ {
@ -297,10 +303,16 @@ namespace Fungus
return; return;
} }
if (localizationFile == null)
{
// No localization file set
return;
}
localizedStrings.Clear(); localizedStrings.Clear();
CsvParser csvParser = new CsvParser(); CsvParser csvParser = new CsvParser();
string[][] csvTable = csvParser.Parse(csvData); string[][] csvTable = csvParser.Parse(localizationFile.text);
if (csvTable.Length <= 1) if (csvTable.Length <= 1)
{ {

Loading…
Cancel
Save