diff --git a/Assets/Fungus/Scripts/Components/Localization.cs b/Assets/Fungus/Scripts/Components/Localization.cs index 68a45b73..bde6070a 100644 --- a/Assets/Fungus/Scripts/Components/Localization.cs +++ b/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'); diff --git a/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs b/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs new file mode 100644 index 00000000..47dd863b --- /dev/null +++ b/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(); + } +} diff --git a/Assets/Fungus/Scripts/Interfaces/ILocalization.cs.meta b/Assets/Fungus/Scripts/Interfaces/ILocalizable.cs.meta similarity index 100% rename from Assets/Fungus/Scripts/Interfaces/ILocalization.cs.meta rename to Assets/Fungus/Scripts/Interfaces/ILocalizable.cs.meta diff --git a/Assets/Fungus/Scripts/Interfaces/ILocalization.cs b/Assets/Fungus/Scripts/Interfaces/ILocalization.cs deleted file mode 100644 index bbc5cd71..00000000 --- a/Assets/Fungus/Scripts/Interfaces/ILocalization.cs +++ /dev/null @@ -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(); - } -}