diff --git a/ImGui.Forms/ImGui.Forms.nuspec b/ImGui.Forms/ImGui.Forms.nuspec index 913c448..0e30196 100644 --- a/ImGui.Forms/ImGui.Forms.nuspec +++ b/ImGui.Forms/ImGui.Forms.nuspec @@ -2,7 +2,7 @@ Imgui.Forms - 1.1.4 + 1.1.5 A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui) onepiecefreak diff --git a/ImGui.Forms/Localization/LocalizedString.cs b/ImGui.Forms/Localization/LocalizedString.cs index 4f55958..562e81b 100644 --- a/ImGui.Forms/Localization/LocalizedString.cs +++ b/ImGui.Forms/Localization/LocalizedString.cs @@ -22,21 +22,6 @@ public struct LocalizedString /// public bool IsEmpty => string.IsNullOrEmpty(_fixedText) && (string.IsNullOrEmpty(_id) || _args == null); - /// - /// Set up a localized string, based on a localization ID. - /// - /// The ID of the localization to return. - public LocalizedString(string id) : this(id, null, Array.Empty>()) - { } - - /// - /// Set up a localized string, based on a localization ID and formatting arguments. - /// - /// The ID of the localization to return. - /// The arguments of the localization to return. - public LocalizedString(string id, params Func[] args) : this(id, null, args) - { } - private LocalizedString(string id, string fixedText, Func[] args) { _locale = null; @@ -56,6 +41,34 @@ private LocalizedString(string id, string fixedText, Func[] args) _fixedText = null; } + /// + /// Set up a localized string, based on a localization ID. + /// + /// The ID of the localization to represent. + public static LocalizedString FromId(string localizationId) + { + return new LocalizedString(localizationId, null, Array.Empty>()); + } + + /// + /// Set up a localized string, based on a localization ID and formatting arguments. + /// + /// The ID of the localization to represent. + /// The arguments of the localization to represent. + public static LocalizedString FromId(string localizationId, params Func[] args) + { + return new LocalizedString(localizationId, null, args); + } + + /// + /// Set up a localized string, based on a fixed text. + /// + /// The fixed text to represent. + public static LocalizedString FromText(string fixedText) + { + return new LocalizedString(null, fixedText ?? string.Empty, Array.Empty>()); + } + public override string ToString() { if (_fixedText != null) @@ -95,7 +108,7 @@ public override bool Equals(object obj) return _id == locStr._id; } - public static implicit operator LocalizedString(string s) => new(null, s ?? string.Empty, Array.Empty>()); + public static implicit operator LocalizedString(string s) => FromText(s); public static implicit operator string(LocalizedString s) => s.ToString(); } }