loc: update localisation

This commit is contained in:
Anna 2021-04-27 20:58:21 -04:00
parent 34943a5cbf
commit 2ae9af4d64
5 changed files with 215 additions and 96 deletions

View File

@ -26,11 +26,6 @@ namespace NoSoliciting {
var label = Loc.Localize("ReportToNoSoliciting", "Report to NoSoliciting");
args.AdditionalItems.Add(new ContextMenuItem(label, this.Report));
// args.AdditionalItems.Add(new ContextMenuItem("Report to NoSoliciting", this.Report) {
// NameJapanese = "NoSolicitingへの報告",
// NameFrench = "Signaler à NoSoliciting",
// NameGerman = "An NoSoliciting melden",
// });
}
private void Report(ContextMenuItemSelectedArgs args) {
@ -54,12 +49,16 @@ namespace NoSoliciting {
Task.Run(async () => {
var status = await this.Plugin.Ui.Report.ReportMessageAsync(message);
switch (status) {
case ReportStatus.Successful:
this.Plugin.Interface.Framework.Gui.Toast.ShowNormal($"Party Finder hosted by {listing.Name} reported successfully.");
case ReportStatus.Successful: {
var msg = Loc.Localize("ReportToastSuccess", "Party Finder listing hosted by {0} reported successfully.");
this.Plugin.Interface.Framework.Gui.Toast.ShowNormal(string.Format(msg, listing.Name));
break;
case ReportStatus.Failure:
this.Plugin.Interface.Framework.Gui.Toast.ShowError($"Failed to report Party Finder hosted by {listing.Name}.");
}
case ReportStatus.Failure: {
var msg = Loc.Localize("ReportToastFailure", "Failed to report Party Finder listing hosted by {0}.");
this.Plugin.Interface.Framework.Gui.Toast.ShowError(string.Format(msg, listing.Name));
break;
}
}
});
}

View File

@ -5,6 +5,7 @@ using System.Net;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using CheapLoc;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin;
@ -52,20 +53,22 @@ namespace NoSoliciting.Interface {
ImGui.SetNextWindowSize(new Vector2(1_000, 350), ImGuiCond.FirstUseEver);
if (!ImGui.Begin("NoSoliciting reporting", ref this._showReporting)) {
var windowTitle = string.Format(Loc.Localize("Reporting", "{0} reporting"), this.Plugin.Name);
if (!ImGui.Begin($"{windowTitle}###NoSoliciting reporting", ref this._showReporting)) {
return;
}
ImGui.TextUnformatted("Click on one of the entries below to report it to the developer as miscategorised.");
ImGui.TextUnformatted(Loc.Localize("ReportHelp", "Click on one of the entries below to report it to the developer as miscategorised."));
if (this.LastReportStatus != ReportStatus.None) {
var status = this.LastReportStatus switch {
ReportStatus.Failure => "failed to send",
ReportStatus.Successful => "sent successfully",
ReportStatus.InProgress => "sending",
_ => "unknown",
ReportStatus.Failure => Loc.Localize("ReportStatusFailure", "failed to send"),
ReportStatus.Successful => Loc.Localize("ReportStatusSuccessful", "sent successfully"),
ReportStatus.InProgress => Loc.Localize("ReportStatusInProgress", "sending"),
_ => Loc.Localize("ReportStatusUnknown", "unknown"),
};
ImGui.TextUnformatted($"Last report status: {status}");
var reportStatus = Loc.Localize("ReportStatusMessage", "Last report status: {0}");
ImGui.TextUnformatted(string.Format(reportStatus, status));
}
ImGui.Separator();
@ -82,17 +85,18 @@ namespace NoSoliciting.Interface {
}
private void ChatTab() {
if (!ImGui.BeginTabItem("Chat##chat-report")) {
var tabTitle = Loc.Localize("ReportChatTab", "Chat");
if (!ImGui.BeginTabItem($"{tabTitle}##chat-report")) {
return;
}
if (ImGui.BeginChild("##chat-messages", new Vector2(-1, -1))) {
if (ImGui.BeginTable("nosol-chat-report-table", 5, TableFlags)) {
ImGui.TableSetupColumn("Timestamp");
ImGui.TableSetupColumn("Channel");
ImGui.TableSetupColumn("Reason");
ImGui.TableSetupColumn("Sender");
ImGui.TableSetupColumn("Message", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn(Loc.Localize("ReportColumnTimestamp", "Timestamp"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnChannel", "Channel"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnReason", "Reason"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnSender", "Sender"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnMessage", "Message"), ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableHeadersRow();
@ -130,7 +134,8 @@ namespace NoSoliciting.Interface {
}
private void PartyFinderTab() {
if (!ImGui.BeginTabItem("Party Finder##pf-report")) {
var tabTitle = Loc.Localize("ReportPartyFinderTab", "Party Finder");
if (!ImGui.BeginTabItem($"{tabTitle}##pf-report")) {
return;
}
@ -152,10 +157,10 @@ namespace NoSoliciting.Interface {
if (ImGui.BeginChild("##pf-messages", new Vector2(-1, -1))) {
if (ImGui.BeginTable("nosol-pf-report-table", 4, TableFlags)) {
ImGui.TableSetupColumn("Timestamp");
ImGui.TableSetupColumn("Reason");
ImGui.TableSetupColumn("Host");
ImGui.TableSetupColumn("Description", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupColumn(Loc.Localize("ReportColumnTimestamp", "Timestamp"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnReason", "Reason"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnHost", "Host"));
ImGui.TableSetupColumn(Loc.Localize("ReportColumnDescription", "Description"), ImGuiTableColumnFlags.WidthStretch);
ImGui.TableSetupScrollFreeze(0, 1);
ImGui.TableHeadersRow();
@ -196,23 +201,19 @@ namespace NoSoliciting.Interface {
private void SetUpReportModal(Message message) {
ImGui.SetNextWindowSize(new Vector2(350, -1));
if (!ImGui.BeginPopupModal($"Report to NoSoliciting###modal-message-{message.Id}")) {
var modalTitle = string.Format(Loc.Localize("ReportModalTitle", "Report to {0}"), this.Plugin.Name);
if (!ImGui.BeginPopupModal($"{modalTitle}###modal-message-{message.Id}")) {
return;
}
ImGui.PushTextWrapPos();
if (!message.Ml) {
ImGui.TextUnformatted("You cannot report messages filtered by definitions. Please switch to machine learning mode.");
goto EndPopup;
}
ImGui.TextUnformatted("Reporting this message will let the developer know that you think this message was incorrectly classified.");
ImGui.TextUnformatted(Loc.Localize("ReportModalHelp1", "Reporting this message will let the developer know that you think this message was incorrectly classified."));
ImGui.TextUnformatted(message.FilterReason != null
? "Specifically, this message WAS filtered but shouldn't have been."
: "Specifically, this message WAS NOT filtered but should have been.");
? Loc.Localize("ReportModalWasFiltered", "Specifically, this message WAS filtered but shouldn't have been.")
: Loc.Localize("ReportModalWasNotFiltered", "Specifically, this message WAS NOT filtered but should have been."));
ImGui.Separator();
@ -221,17 +222,18 @@ namespace NoSoliciting.Interface {
ImGui.Separator();
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1f, 0f, 0f, 1f));
ImGui.TextUnformatted("NoSoliciting only works for English messages. Do not report non-English messages.");
ImGui.TextUnformatted(Loc.Localize("ReportModalHelp2", "NoSoliciting only works for English messages. Do not report non-English messages."));
ImGui.PopStyleColor();
ImGui.Separator();
if (message.FilterReason == "custom") {
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1f, 0f, 0f, 1f));
ImGui.TextUnformatted("You cannot report messages filtered because of a custom filter.");
ImGui.TextUnformatted(Loc.Localize("ReportModalCustom", "You cannot report messages filtered because of a custom filter."));
ImGui.PopStyleColor();
} else {
if (ImGui.Button("Report")) {
var buttonTitle = Loc.Localize("ReportModalReport", "Report");
if (ImGui.Button($"{buttonTitle}##report-submit-{message.Id}")) {
this.ReportMessage(message);
ImGui.CloseCurrentPopup();
}
@ -239,7 +241,8 @@ namespace NoSoliciting.Interface {
ImGui.SameLine();
}
if (ImGui.Button("Copy to clipboard")) {
var copyButton = Loc.Localize("ReportModalCopy", "Copy to clipboard");
if (ImGui.Button($"{copyButton}##report-copy-{message.Id}")) {
ImGui.SetClipboardText(message.Content.TextValue);
}
@ -252,8 +255,8 @@ namespace NoSoliciting.Interface {
ImGui.SameLine();
EndPopup:
if (ImGui.Button("Cancel")) {
var cancelButton = Loc.Localize("ReportModalCancel", "Cancel");
if (ImGui.Button($"{cancelButton}##report-cancel-{message.Id}")) {
ImGui.CloseCurrentPopup();
}

View File

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Reflection;
using System.Text.RegularExpressions;
using CheapLoc;
using Dalamud.Interface;
using Dalamud.Plugin;
using ImGuiNET;
using NoSoliciting.Ml;
@ -41,7 +39,7 @@ namespace NoSoliciting.Interface {
}
public void Draw() {
var windowTitle = Loc.Localize("Settings", "NoSoliciting settings");
var windowTitle = string.Format(Loc.Localize("Settings", "{0} settings"), this.Plugin.Name);
if (!this.ShowSettings || !ImGui.Begin($"{windowTitle}###NoSoliciting settings", ref this._showSettings)) {
return;
}
@ -102,11 +100,11 @@ namespace NoSoliciting.Interface {
return;
}
ImGui.TextUnformatted($"Version: {this.Plugin.MlFilter?.Version}");
ImGui.TextUnformatted($"Model status: {this.Plugin.MlStatus.Description()}");
ImGui.TextUnformatted(string.Format(Loc.Localize("ModelTabVersion", "Version: {0}"), this.Plugin.MlFilter?.Version));
ImGui.TextUnformatted(string.Format(Loc.Localize("ModelTabStatus", "Model status: {0}"), this.Plugin.MlStatus.Description()));
var lastError = MlFilter.LastError;
if (lastError != null) {
ImGui.TextUnformatted($"Last error: {lastError}");
ImGui.TextUnformatted(string.Format(Loc.Localize("ModelTabError", "Last error: {0}"), lastError));
}
if (ImGui.Button(Loc.Localize("UpdateModel", "Update model"))) {
@ -239,7 +237,7 @@ namespace NoSoliciting.Interface {
}
var customPf = this.Plugin.Config.CustomPFFilter;
if (ImGui.Checkbox(Loc.Localize("EnableCustomPartyFinderFilters", "Enabled custom Party Finder filters"), ref customPf)) {
if (ImGui.Checkbox(Loc.Localize("EnableCustomPartyFinderFilters", "Enable custom Party Finder filters"), ref customPf)) {
this.Plugin.Config.CustomPFFilter = customPf;
this.Plugin.Config.Save();
}

View File

@ -45,6 +45,7 @@ namespace NoSoliciting {
this.Interface = pluginInterface;
Loc.Setup(Resourcer.Resource.AsString("Resources/en.json"), Assembly.GetAssembly(typeof(Plugin)));
Loc.ExportLocalizable();
this.Config = this.Interface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
this.Config.Initialise(this.Interface);
@ -73,8 +74,6 @@ namespace NoSoliciting {
}
if (disposing) {
Loc.ExportLocalizable();
this.Filter.Dispose();
this.MlFilter?.Dispose();
this.ContextMenu.Dispose();

View File

@ -1,170 +1,290 @@
{
"ReportToNoSoliciting": {
"message": "Report to NoSoliciting",
"description": "ContextMenu.OnOpenContextMenu"
"description": "The context menu item shown for reporting in the Party Finder"
},
"ReportToastSuccess": {
"message": "Party Finder listing hosted by {0} reported successfully.",
"description": "The toast shown on a successful report. {0} is replaced by a player's name"
},
"ReportToastFailure": {
"message": "Failed to report Party Finder listing hosted by {0}.",
"description": "The toast shown on a failed report. {0} is replaced by a player's name"
},
"TradeCategory": {
"message": "Trade ads",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"FreeCompanyCategory": {
"message": "Free Company ads",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"NormalCategory": {
"message": "Normal messages",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"PhishingCategory": {
"message": "Phishing messages",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"RmtContentCategory": {
"message": "RMT (content)",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"RmtGilCategory": {
"message": "RMT (gil)",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"RoleplayingCategory": {
"message": "Roleplaying ads",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"StaticCategory": {
"message": "Static recruitment",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"CommunityCategory": {
"message": "Community ads",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"StaticSubCategory": {
"message": "Static substitutes",
"description": "MessageCategoryExt.Name"
"description": "A machine learning category name"
},
"TradeDescription": {
"message": "Messages advertising trading items or services for gil, such as omnicrafters looking for work or people selling rare items off the market board",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"FreeCompanyDescription": {
"message": "Advertisements for Free Companies",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"NormalDescription": {
"message": "Normal messages that should not be filtered",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"PhishingDescription": {
"message": "Messages trying to trick you into revealing your account details in order to steal your account",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"RmtContentDescription": {
"message": "Real-money trade involving content (also known as content sellers)",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"RmtGilDescription": {
"message": "Real-money trade involving gil or items (also known as RMT bots)",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"RoleplayingDescription": {
"message": "Advertisements for personal RP, RP communities, venues, or anything else related to roleplaying",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"StaticDescription": {
"message": "Statics looking for members or players looking for a static",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"CommunityDescription": {
"message": "Advertisements for general-purpose communities, generally Discord servers",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"StaticSubDescription": {
"message": "Statics looking for fill-ins of missing members for clears",
"description": "MessageCategoryExt.Description"
"description": "A machine learning category description"
},
"Reporting": {
"message": "{0} reporting",
"description": "The title of the reporting window. {0} is replaced with the plugin name"
},
"ReportHelp": {
"message": "Click on one of the entries below to report it to the developer as miscategorised.",
"description": "A help message shown at the top of the reporting window"
},
"ReportStatusFailure": {
"message": "failed to send",
"description": "The status to be shown in ReportStatusMessage for failed reports"
},
"ReportStatusSuccessful": {
"message": "sent successfully",
"description": "The status to be shown in ReportStatusMessage for successful reports"
},
"ReportStatusInProgress": {
"message": "sending",
"description": "The status to be shown in ReportStatusMessage for in-progress reports"
},
"ReportStatusUnknown": {
"message": "unknown",
"description": "The status to be shown in ReportStatusMessage for reports with an unknown status"
},
"ReportStatusMessage": {
"message": "Last report status: {0}",
"description": "Shown on the reporting window to indicate the status of the last report"
},
"ReportChatTab": {
"message": "Chat",
"description": "The tab in the reporting window for chat messages"
},
"ReportColumnTimestamp": {
"message": "Timestamp",
"description": "The column in the reporting window for timestamps"
},
"ReportColumnChannel": {
"message": "Channel",
"description": "The column in the reporting window for chat channels"
},
"ReportColumnReason": {
"message": "Reason",
"description": "The column in the reporting window for filter reasons"
},
"ReportColumnSender": {
"message": "Sender",
"description": "The column in the reporting window for senders"
},
"ReportColumnMessage": {
"message": "Message",
"description": "The column in the reporting window for chat messages"
},
"ReportPartyFinderTab": {
"message": "Party Finder",
"description": "The tab in the reporting window for Party Finder listings"
},
"ReportColumnHost": {
"message": "Host",
"description": "The column in the reporting window for Party Finder hosts"
},
"ReportColumnDescription": {
"message": "Description",
"description": "The column in the reporting window for Party Finder descriptions"
},
"ReportModalTitle": {
"message": "Report to {0}",
"description": "The window title for the reporting window. The {0} is replaced with the plugin name"
},
"ReportModalHelp1": {
"message": "Reporting this message will let the developer know that you think this message was incorrectly classified.",
"description": "Help text shown when attempting to report a message"
},
"ReportModalWasNotFiltered": {
"message": "Specifically, this message WAS NOT filtered but should have been.",
"description": "Help text shown when attempting to report a false negative"
},
"ReportModalWasFiltered": {
"message": "Specifically, this message WAS filtered but shouldn't have been.",
"description": "Help text shown when attempting to report a false positive"
},
"ReportModalHelp2": {
"message": "NoSoliciting only works for English messages. Do not report non-English messages.",
"description": "Help text shown when attempting to report a message"
},
"ReportModalCustom": {
"message": "You cannot report messages filtered because of a custom filter.",
"description": "Error text shown when attempting to report a message filtered by a custom filter"
},
"ReportModalReport": {
"message": "Report",
"description": "The button used to report a message"
},
"ReportModalCopy": {
"message": "Copy to clipboard",
"description": "The button used to copy a message to the clipboard"
},
"ReportModalCancel": {
"message": "Cancel",
"description": "The button used to cancel reporting a message"
},
"Settings": {
"message": "NoSoliciting settings",
"description": "Settings.Draw"
"message": "{0} settings",
"description": "The title of the settings window. The {0} is replaced with the plugin name"
},
"AdvancedMode": {
"message": "Advanced mode",
"description": "Settings.Draw"
"description": "A checkbox used to enable advanced options"
},
"OtherTab": {
"message": "Other",
"description": "Settings.Draw"
"description": "The tab used for other settings"
},
"LogFilteredPfs": {
"message": "Log filtered PFs",
"description": "Settings.Draw"
"description": "A checkbox used to enable PF filter logs"
},
"LogFilteredMessages": {
"message": "Log filtered messages",
"description": "Settings.Draw"
"description": "A checkbox used to enable chat filter logs"
},
"ShowReportingWindow": {
"message": "Show reporting window",
"description": "Settings.Draw"
"description": "A button used to show the reporting window"
},
"ModelTab": {
"message": "Model",
"description": "Settings.DrawMachineLearningConfig"
"description": "The settings tab for machine learning model settings"
},
"ModelTabVersion": {
"message": "Version: {0}",
"description": "The version of the machine learning model. The {0} is replaced with the actual version"
},
"ModelTabStatus": {
"message": "Model status: {0}",
"description": "The status of the machine learning model. The {0} is replaced with the actual status"
},
"ModelTabError": {
"message": "Last error: {0}",
"description": "The last error encountered when loading the machine learning model. The {0} is replaced with the actual error"
},
"UpdateModel": {
"message": "Update model",
"description": "Settings.DrawMachineLearningConfig"
"description": "A button used to update the machine learning model"
},
"FiltersTab": {
"message": "Filters",
"description": "Settings.DrawBasicMachineLearningConfig"
"description": "The settings tab for configuring filters"
},
"AdvancedWarning1": {
"message": "Do not change advanced settings unless you know what you are doing.",
"description": "Settings.DrawAdvancedMachineLearningConfig"
"description": "Help text shown in the filters tab"
},
"AdvancedWarning2": {
"message": "The machine learning model was trained with certain channels in mind.",
"description": "Settings.DrawAdvancedMachineLearningConfig"
"description": "Help text shown in the filters tab"
},
"OtherFiltersTab": {
"message": "Other filters",
"description": "Settings.DrawOtherFilters"
"description": "The settings tab for other filters"
},
"ChatFilters": {
"message": "Chat filters",
"description": "Settings.DrawOtherFilters"
"description": "The section header for other chat filters"
},
"EnableCustomChatFilters": {
"message": "Enable custom chat filters",
"description": "Settings.DrawOtherFilters"
"description": "A checkbox used to enable custom chat filters"
},
"PartyFinderFilters": {
"message": "Party Finder filters",
"description": "Settings.DrawOtherFilters"
"description": "The section header for other Party Finder filters"
},
"FilterIlvlPfs": {
"message": "Filter PFs with item level above maximum",
"description": "Settings.DrawOtherFilters"
"description": "A checkbox used to enable filtering Party Finders with item levels above maximum"
},
"FilterPrivatePfs": {
"message": "Apply filters to private Party Finder listings",
"description": "Settings.DrawOtherFilters"
"description": "A checkbox used to enable filtering private Party Finder listings"
},
"EnableCustomPartyFinderFilters": {
"message": "Enabled custom Party Finder filters",
"description": "Settings.DrawOtherFilters"
"message": "Enable custom Party Finder filters",
"description": "A checkbox used to enable custom Party Finder filters"
},
"SubstringsToFilter": {
"message": "Substrings to filter",
"description": "Settings.DrawCustom"
"description": "A column of text boxes containing substrings to filter"
},
"RegularExpressionsToFilter": {
"message": "Regular expressions to filter",
"description": "Settings.DrawCustom"
"description": "A column of text boxes containing regular expressions to filter"
},
"SaveFilters": {
"message": "Save filters",
"description": "Settings.DrawCustom"
"description": "A button used to save custom filters after editing"
}
}