From a4ba1fa133009008d82f10ed4e19cbbf80b42fbb Mon Sep 17 00:00:00 2001 From: onepiecefreak3 Date: Sun, 27 Oct 2024 10:25:58 +0100 Subject: [PATCH] Call Initialize() from BaseLocalizer in derivation instead; --- ImGui.Forms/ImGui.Forms.nuspec | 2 +- ImGui.Forms/Localization/BaseLocalizer.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ImGui.Forms/ImGui.Forms.nuspec b/ImGui.Forms/ImGui.Forms.nuspec index 223a9ae..9f73fcc 100644 --- a/ImGui.Forms/ImGui.Forms.nuspec +++ b/ImGui.Forms/ImGui.Forms.nuspec @@ -2,7 +2,7 @@ Imgui.Forms - 1.2.0 + 1.2.1 A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui) onepiecefreak diff --git a/ImGui.Forms/Localization/BaseLocalizer.cs b/ImGui.Forms/Localization/BaseLocalizer.cs index 2620a88..554abed 100644 --- a/ImGui.Forms/Localization/BaseLocalizer.cs +++ b/ImGui.Forms/Localization/BaseLocalizer.cs @@ -5,21 +5,13 @@ namespace ImGui.Forms.Localization { public abstract class BaseLocalizer : ILocalizer { - private readonly IDictionary _localizations; + private IDictionary _localizations; protected abstract string DefaultLocale { get; } protected abstract string UndefinedValue { get; } public string CurrentLocale { get; private set; } - public BaseLocalizer() - { - _localizations = GetLocalizations(); - - // HINT: SetCurrentLocale is not used on purpose, to not apply override logic in case of failure - CurrentLocale = GetInitialLocale(); - } - public IList GetLocales() { return _localizations.Keys.ToArray(); @@ -64,6 +56,14 @@ public string Localize(string localizationId, params object[] args) return UndefinedValue; } + protected void Initialize() + { + _localizations = GetLocalizations(); + + // HINT: SetCurrentLocale is not used on purpose, to not apply override logic in case of failure + CurrentLocale = GetInitialLocale(); + } + protected abstract IList InitializeLocalizations(); protected abstract string InitializeLocale();