feat: add option to choose language source
This commit is contained in:
parent
03322b2327
commit
7c84ff93f3
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using Dalamud.Plugin;
|
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using NoSoliciting.Ml;
|
using NoSoliciting.Ml;
|
||||||
using NoSoliciting.Resources;
|
using NoSoliciting.Resources;
|
||||||
|
@ -61,21 +60,7 @@ namespace NoSoliciting.Interface {
|
||||||
|
|
||||||
this.DrawOtherFilters();
|
this.DrawOtherFilters();
|
||||||
|
|
||||||
if (ImGui.BeginTabItem(Language.OtherTab)) {
|
this.DrawOtherTab();
|
||||||
var logFilteredPfs = this.Plugin.Config.LogFilteredPfs;
|
|
||||||
if (ImGui.Checkbox(Language.LogFilteredPfs, ref logFilteredPfs)) {
|
|
||||||
this.Plugin.Config.LogFilteredPfs = logFilteredPfs;
|
|
||||||
this.Plugin.Config.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
var logFilteredMessages = this.Plugin.Config.LogFilteredChat;
|
|
||||||
if (ImGui.Checkbox(Language.LogFilteredMessages, ref logFilteredMessages)) {
|
|
||||||
this.Plugin.Config.LogFilteredChat = logFilteredMessages;
|
|
||||||
this.Plugin.Config.Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndTabItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.EndTabBar();
|
ImGui.EndTabBar();
|
||||||
|
|
||||||
|
@ -329,5 +314,32 @@ namespace NoSoliciting.Interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private void DrawOtherTab() {
|
||||||
|
if (!ImGui.BeginTabItem(Language.OtherTab)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var useGameLanguage = this.Plugin.Config.FollowGameLanguage;
|
||||||
|
if (ImGui.Checkbox(Language.OtherGameLanguage, ref useGameLanguage)) {
|
||||||
|
this.Plugin.Config.FollowGameLanguage = useGameLanguage;
|
||||||
|
this.Plugin.Config.Save();
|
||||||
|
this.Plugin.ConfigureLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
var logFilteredPfs = this.Plugin.Config.LogFilteredPfs;
|
||||||
|
if (ImGui.Checkbox(Language.LogFilteredPfs, ref logFilteredPfs)) {
|
||||||
|
this.Plugin.Config.LogFilteredPfs = logFilteredPfs;
|
||||||
|
this.Plugin.Config.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
var logFilteredMessages = this.Plugin.Config.LogFilteredChat;
|
||||||
|
if (ImGui.Checkbox(Language.LogFilteredMessages, ref logFilteredMessages)) {
|
||||||
|
this.Plugin.Config.LogFilteredChat = logFilteredMessages;
|
||||||
|
this.Plugin.Config.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTabItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,9 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Dalamud;
|
||||||
using NoSoliciting.Interface;
|
using NoSoliciting.Interface;
|
||||||
using NoSoliciting.Ml;
|
using NoSoliciting.Ml;
|
||||||
using Resourcer;
|
|
||||||
using XivCommon;
|
using XivCommon;
|
||||||
|
|
||||||
namespace NoSoliciting {
|
namespace NoSoliciting {
|
||||||
|
@ -44,14 +44,13 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
this.Interface = pluginInterface;
|
this.Interface = pluginInterface;
|
||||||
|
|
||||||
Util.PreLoadResourcesFromMainAssembly();
|
|
||||||
|
|
||||||
Resources.Language.Culture = new CultureInfo(this.Interface.UiLanguage);
|
|
||||||
this.Interface.OnLanguageChanged += OnLanguageUpdate;
|
|
||||||
|
|
||||||
this.Config = this.Interface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
|
this.Config = this.Interface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
|
||||||
this.Config.Initialise(this.Interface);
|
this.Config.Initialise(this.Interface);
|
||||||
|
|
||||||
|
Util.PreLoadResourcesFromMainAssembly();
|
||||||
|
this.ConfigureLanguage();
|
||||||
|
this.Interface.OnLanguageChanged += this.OnLanguageUpdate;
|
||||||
|
|
||||||
this.Common = new XivCommonBase(this.Interface, Hooks.PartyFinder | Hooks.ContextMenu);
|
this.Common = new XivCommonBase(this.Interface, Hooks.PartyFinder | Hooks.ContextMenu);
|
||||||
|
|
||||||
this.Ui = new PluginUi(this);
|
this.Ui = new PluginUi(this);
|
||||||
|
@ -82,13 +81,29 @@ namespace NoSoliciting {
|
||||||
this.Commands.Dispose();
|
this.Commands.Dispose();
|
||||||
this.Ui.Dispose();
|
this.Ui.Dispose();
|
||||||
this.Common.Dispose();
|
this.Common.Dispose();
|
||||||
this.Interface.OnLanguageChanged -= OnLanguageUpdate;
|
this.Interface.OnLanguageChanged -= this.OnLanguageUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._disposedValue = true;
|
this._disposedValue = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnLanguageUpdate(string langCode) {
|
private void OnLanguageUpdate(string langCode) {
|
||||||
|
this.ConfigureLanguage(langCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ConfigureLanguage(string? langCode = null) {
|
||||||
|
if (this.Config.FollowGameLanguage) {
|
||||||
|
langCode = this.Interface.ClientState.ClientLanguage switch {
|
||||||
|
ClientLanguage.Japanese => "ja",
|
||||||
|
ClientLanguage.English => "en",
|
||||||
|
ClientLanguage.German => "de",
|
||||||
|
ClientLanguage.French => "fr",
|
||||||
|
_ => throw new ArgumentOutOfRangeException(),
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
langCode ??= this.Interface.UiLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
Resources.Language.Culture = new CultureInfo(langCode);
|
Resources.Language.Culture = new CultureInfo(langCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace NoSoliciting {
|
||||||
|
|
||||||
public bool FilterHugeItemLevelPFs { get; set; }
|
public bool FilterHugeItemLevelPFs { get; set; }
|
||||||
|
|
||||||
|
public bool FollowGameLanguage { get; set; }
|
||||||
|
|
||||||
public HashSet<MessageCategory> BasicMlFilters { get; set; } = new() {
|
public HashSet<MessageCategory> BasicMlFilters { get; set; } = new() {
|
||||||
MessageCategory.RmtGil,
|
MessageCategory.RmtGil,
|
||||||
MessageCategory.RmtContent,
|
MessageCategory.RmtContent,
|
||||||
|
|
9
NoSoliciting/Resources/Language.Designer.cs
generated
9
NoSoliciting/Resources/Language.Designer.cs
generated
|
@ -258,6 +258,15 @@ namespace NoSoliciting.Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Use the game's language setting instead of Dalamud's.
|
||||||
|
/// </summary>
|
||||||
|
internal static string OtherGameLanguage {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("OtherGameLanguage", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Other.
|
/// Looks up a localized string similar to Other.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -234,4 +234,7 @@
|
||||||
<data name="ReportToastFailure" xml:space="preserve">
|
<data name="ReportToastFailure" xml:space="preserve">
|
||||||
<value>Failed to report Party Finder listing hosted by {0}.</value>
|
<value>Failed to report Party Finder listing hosted by {0}.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="OtherGameLanguage" xml:space="preserve">
|
||||||
|
<value>Use the game's language setting instead of Dalamud's</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
Loading…
Reference in New Issue
Block a user