Skip to content

Commit

Permalink
Make SettingCheckBoxBase and SettingDropDownBase can be i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
frg2089 committed Apr 30, 2024
1 parent 260ec47 commit 5b47ceb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 15 additions & 0 deletions DTAConfig/Settings/SettingCheckBoxBase.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using ClientCore.I18N;
using ClientGUI;
using Rampastring.Tools;
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;

namespace DTAConfig.Settings
{
Expand Down Expand Up @@ -74,6 +76,9 @@ public XNAClientCheckBox ParentCheckBox

protected override void ParseControlINIAttribute(IniFile iniFile, string key, string value)
{
static string Localize(XNAControl control, string attributeName, string defaultValue, bool notify = true)
=> Translation.Instance.LookUp(control, attributeName, defaultValue, notify);

switch (key)
{
case "Checked":
Expand All @@ -98,6 +103,16 @@ protected override void ParseControlINIAttribute(IniFile iniFile, string key, st
}

base.ParseControlINIAttribute(iniFile, key, value);

switch (key)
{
case nameof(Text):
Text = Localize(this, nameof(Text), Text);
break;
case nameof(ToolTip):
ToolTipText = Localize(this, nameof(ToolTip), ToolTipText);
break;
}
}

public abstract void Load();
Expand Down
10 changes: 8 additions & 2 deletions DTAConfig/Settings/SettingDropDownBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ClientCore.Extensions;
using ClientCore.I18N;
using ClientCore.I18N;
using ClientGUI;
using Rampastring.Tools;
using Rampastring.XNAUI;
Expand Down Expand Up @@ -77,6 +76,13 @@ static string Localize(XNAControl control, string attributeName, string defaultV
}

base.ParseControlINIAttribute(iniFile, key, value);

switch (key)
{
case nameof(ToolTip):
ToolTipText = Localize(this, nameof(ToolTip), ToolTipText);
break;
}
}

public abstract void Load();
Expand Down

0 comments on commit 5b47ceb

Please sign in to comment.