diff --git a/CLUNL.Localization/CLUNL.Localization.csproj b/CLUNL.Localization/CLUNL.Localization.csproj index 50c0958..d75b24c 100644 --- a/CLUNL.Localization/CLUNL.Localization.csproj +++ b/CLUNL.Localization/CLUNL.Localization.csproj @@ -3,14 +3,14 @@ netstandard2.1 True - 0.0.5.0 + 0.0.6.0 https://github.com/creeperlv/CLUNL https://github.com/creeperlv/CLUNL Localization processing part of Creeper Lv's Universal dotNet Library Creeper Lv Creeper Lv - Copyright (C) 2020-2021 Creeper Lv + Copyright (C) 2020-2022 Creeper Lv CLUNL.Localization, please see github for release note. LICENSE diff --git a/CLUNL.Localization/ILocalizable.cs b/CLUNL.Localization/ILocalizable.cs new file mode 100644 index 0000000..acf6b0c --- /dev/null +++ b/CLUNL.Localization/ILocalizable.cs @@ -0,0 +1,13 @@ +namespace CLUNL.Localization +{ + /// + /// Mark a class is localizable + /// + public interface ILocalizable + { + /// + /// + /// + void ApplyLocalization(); + } +} diff --git a/CLUNL.Localization/LocalizedString.cs b/CLUNL.Localization/LocalizedString.cs new file mode 100644 index 0000000..68f5fff --- /dev/null +++ b/CLUNL.Localization/LocalizedString.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Text; + +namespace CLUNL.Localization +{ + /// + /// Localized via Language. + /// + public class LocalizedString + { + /// + /// Initialize the string with LanguageID and fallback. + /// + /// + /// + public LocalizedString(string ID,string Fallback) + { + this.ID = ID; + this.Fallback = Fallback; + } + private string ID; + private string Fallback; + /// + /// Return the localized string. + /// + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public override string ToString() + { + return Language.Find(ID, Fallback); + } + /// + /// Return the value from ToString(); + /// + /// + public static implicit operator string(LocalizedString L) + { + return L.ToString(); + } + } +}