Skip to content

Commit

Permalink
Call Initialize() from BaseLocalizer in derivation instead;
Browse files Browse the repository at this point in the history
  • Loading branch information
onepiecefreak3 committed Oct 27, 2024
1 parent 9fcdbc3 commit a4ba1fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ImGui.Forms/ImGui.Forms.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Imgui.Forms</id>
<version>1.2.0</version>
<version>1.2.1</version>
<description>A WinForms-inspired object-oriented framework around Dear ImGui (https://github.com/ocornut/imgui)</description>

<authors>onepiecefreak</authors>
Expand Down
18 changes: 9 additions & 9 deletions ImGui.Forms/Localization/BaseLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ namespace ImGui.Forms.Localization
{
public abstract class BaseLocalizer : ILocalizer
{
private readonly IDictionary<string, LanguageInfo> _localizations;
private IDictionary<string, LanguageInfo> _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<string> GetLocales()
{
return _localizations.Keys.ToArray();
Expand Down Expand Up @@ -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<LanguageInfo> InitializeLocalizations();
protected abstract string InitializeLocale();

Expand Down

0 comments on commit a4ba1fa

Please sign in to comment.