Browse Source

Reverted Localisation interface

master
Christopher 8 years ago
parent
commit
a78ab7ccdb
  1. 33
      Assets/Fungus/Scripts/Components/Localization.cs
  2. 35
      Assets/Fungus/Scripts/Interfaces/ILocalizable.cs
  3. 0
      Assets/Fungus/Scripts/Interfaces/ILocalizable.cs.meta
  4. 83
      Assets/Fungus/Scripts/Interfaces/ILocalization.cs

33
Assets/Fungus/Scripts/Components/Localization.cs

@ -16,7 +16,7 @@ namespace Fungus
/// <summary>
/// Multi-language localization support.
/// </summary>
public class Localization : MonoBehaviour, ILocalization, ISubstitutionHandler
public class Localization : MonoBehaviour, ISubstitutionHandler
{
/// <summary>
/// Temp storage for a single item of standard text and its localizations.
@ -247,19 +247,34 @@ namespace Fungus
}
}
#region ILocalization interface
#region Public methods
/// <summary>
/// Language to use at startup, usually defined by a two letter language code (e.g DE = German).
/// </summary>
public virtual string ActiveLanguage { get { return activeLanguage; } }
/// <summary>
/// CSV file containing localization data which can be easily edited in a spreadsheet tool.
/// </summary>
public virtual TextAsset LocalizationFile { get { return localizationFile; } set { localizationFile = value; } }
/// <summary>
/// Stores any notification message from export / import methods.
/// </summary>
public virtual string NotificationText { get { return notificationText; } set { notificationText = value; } }
/// <summary>
/// Clears the cache of localizeable objects.
/// </summary>
public virtual void ClearLocalizeableCache()
{
localizeableObjects.Clear();
}
/// <summary>
/// Convert all text items and localized strings to an easy to edit CSV format.
/// </summary>
public virtual string GetCSVData()
{
// Collect all the text items present in the scene
@ -319,6 +334,10 @@ namespace Fungus
return csvData;
}
/// <summary>
/// Scan a localization CSV file and copies the strings for the specified language code
/// into the text properties of the appropriate scene objects.
/// </summary>
public virtual void SetActiveLanguage(string languageCode, bool forceUpdateSceneText = false)
{
if (!Application.isPlaying)
@ -411,6 +430,9 @@ namespace Fungus
}
}
/// <summary>
/// Populates the text property of a single scene object with a new text value.
/// </summary>
public virtual bool PopulateTextProperty(string stringId, string newText)
{
// Ensure that all localizeable objects have been cached
@ -430,6 +452,10 @@ namespace Fungus
return false;
}
/// <summary>
/// Returns all standard text for localizeable text in the scene using an
/// easy to edit custom text format.
/// </summary>
public virtual string GetStandardText()
{
// Collect all the text items present in the scene
@ -451,6 +477,9 @@ namespace Fungus
return textData;
}
/// <summary>
/// Sets standard text on scene objects by parsing a text data file.
/// </summary>
public virtual void SetStandardText(string textData)
{
string[] lines = textData.Split('\n');

35
Assets/Fungus/Scripts/Interfaces/ILocalizable.cs

@ -0,0 +1,35 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// An item of localizeable text.
/// </summary>
public interface ILocalizable
{
/// <summary>
/// Gets the standard (non-localized) text.
/// </summary>
string GetStandardText();
/// <summary>
/// Sets the standard (non-localized) text.
/// </summary>
/// <param name="standardText">Standard text.</param>
void SetStandardText(string standardText);
/// <summary>
/// Gets the description used to help localizers.
/// </summary>
/// <returns>The description.</returns>
string GetDescription();
/// <summary>
/// Gets the unique string identifier.
/// </summary>
string GetStringId();
}
}

0
Assets/Fungus/Scripts/Interfaces/ILocalization.cs.meta → Assets/Fungus/Scripts/Interfaces/ILocalizable.cs.meta

83
Assets/Fungus/Scripts/Interfaces/ILocalization.cs

@ -1,83 +0,0 @@
// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
namespace Fungus
{
/// <summary>
/// Multi-language localization support.
/// </summary>
public interface ILocalization
{
/// <summary>
/// Language to use at startup, usually defined by a two letter language code (e.g DE = German).
/// </summary>
string ActiveLanguage { get; }
/// <summary>
/// CSV file containing localization data which can be easily edited in a spreadsheet tool.
/// </summary>
TextAsset LocalizationFile { get; }
/// <summary>
/// Stores any notification message from export / import methods.
/// </summary>
string NotificationText { get; set; }
/// <summary>
/// Convert all text items and localized strings to an easy to edit CSV format.
/// </summary>
string GetCSVData();
/// <summary>
/// Scan a localization CSV file and copies the strings for the specified language code
/// into the text properties of the appropriate scene objects.
/// </summary>
void SetActiveLanguage(string languageCode, bool forceUpdateSceneText = false);
/// <summary>
/// Populates the text property of a single scene object with a new text value.
/// </summary>
bool PopulateTextProperty(string stringId, string newText);
/// <summary>
/// Returns all standard text for localizeable text in the scene using an
/// easy to edit custom text format.
/// </summary>
string GetStandardText();
/// <summary>
/// Sets standard text on scene objects by parsing a text data file.
/// </summary>
void SetStandardText(string textData);
}
/// <summary>
/// An item of localizeable text.
/// </summary>
public interface ILocalizable
{
/// <summary>
/// Gets the standard (non-localized) text.
/// </summary>
string GetStandardText();
/// <summary>
/// Sets the standard (non-localized) text.
/// </summary>
/// <param name="standardText">Standard text.</param>
void SetStandardText(string standardText);
/// <summary>
/// Gets the description used to help localizers.
/// </summary>
/// <returns>The description.</returns>
string GetDescription();
/// <summary>
/// Gets the unique string identifier.
/// </summary>
string GetStringId();
}
}
Loading…
Cancel
Save