From 62af691419622bf85d8c853c81b149cc3e34b419 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Wed, 28 Feb 2024 01:05:47 +0900 Subject: [PATCH] More notification localizations --- .../Internal/NotificationConstants.cs | 20 +++++++++++-------- Dalamud/Localization.cs | 2 +- Dalamud/Utility/DateTimeSpanExtensions.cs | 16 ++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs b/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs index 50536baa3..de212160c 100644 --- a/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs +++ b/Dalamud/Interface/ImGuiNotification/Internal/NotificationConstants.cs @@ -1,5 +1,7 @@ using System.Numerics; +using CheapLoc; + using Dalamud.Interface.Colors; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Utility; @@ -21,10 +23,8 @@ internal static class NotificationConstants // .. action buttons .. // ................................. - /// The string to show in place of this_plugin if the notification is shown by Dalamud. - public const string DefaultInitiator = "Dalamud"; - /// The string to measure size of, to decide the width of notification windows. + /// Probably not worth localizing. public const string NotificationWidthMeasurementString = "The width of this text will decide the width\n" + "of the notification window."; @@ -113,8 +113,12 @@ internal static class NotificationConstants /// Gets the thickness of the focus indicator rectangle. public static float FocusIndicatorThickness => MathF.Round(3 * ImGuiHelpers.GlobalScale); + /// Gets the string to show in place of this_plugin if the notification is shown by Dalamud. + public static string DefaultInitiator => Loc.Localize("NotificationConstants.DefaultInitiator", "Dalamud"); + /// Gets the string format of the initiator name field, if the initiator is unloaded. - public static string UnloadedInitiatorNameFormat => "{0} (unloaded)"; + public static string UnloadedInitiatorNameFormat => + Loc.Localize("NotificationConstants.UnloadedInitiatorNameFormat", "{0} (unloaded)"); /// Gets the color corresponding to the notification type. /// The notification type. @@ -148,10 +152,10 @@ internal static class NotificationConstants public static string? ToTitle(this NotificationType type) => type switch { NotificationType.None => null, - NotificationType.Success => NotificationType.Success.ToString(), - NotificationType.Warning => NotificationType.Warning.ToString(), - NotificationType.Error => NotificationType.Error.ToString(), - NotificationType.Info => NotificationType.Info.ToString(), + NotificationType.Success => Loc.Localize("NotificationConstants.Title.Success", "Success"), + NotificationType.Warning => Loc.Localize("NotificationConstants.Title.Warning", "Warning"), + NotificationType.Error => Loc.Localize("NotificationConstants.Title.Error", "Error"), + NotificationType.Info => Loc.Localize("NotificationConstants.Title.Info", "Info"), _ => null, }; } diff --git a/Dalamud/Localization.cs b/Dalamud/Localization.cs index 39312ac52..a9b0cf93d 100644 --- a/Dalamud/Localization.cs +++ b/Dalamud/Localization.cs @@ -70,7 +70,7 @@ public class Localization : IServiceType public CultureInfo DalamudLanguageCultureInfo { get; private set; } /// - /// Gets an instance of that corresponds to . + /// Gets an instance of that corresponds to . /// /// The language code which should be in . /// The corresponding instance of . diff --git a/Dalamud/Utility/DateTimeSpanExtensions.cs b/Dalamud/Utility/DateTimeSpanExtensions.cs index 8f6a2a7ec..8422a4a26 100644 --- a/Dalamud/Utility/DateTimeSpanExtensions.cs +++ b/Dalamud/Utility/DateTimeSpanExtensions.cs @@ -11,7 +11,7 @@ namespace Dalamud.Utility; /// /// Utility functions for and . /// -internal static class DateTimeSpanExtensions +public static class DateTimeSpanExtensions { private static readonly ModuleLog Log = new(nameof(DateTimeSpanExtensions)); @@ -34,16 +34,12 @@ internal static class DateTimeSpanExtensions var region = 0; if (framework is not null) region = framework->Region; - switch (region) + return region switch { - case 0: // jp - default: - return when.ToString("yyyy-MM-dd HH:mm:ss"); - case 1: // na - return when.ToString("MM/dd/yyyy HH:mm:ss"); - case 2: // eu - return when.ToString("dd-mm-yyyy HH:mm:ss"); - } + 1 => when.ToString("MM/dd/yyyy HH:mm:ss"), // na + 2 => when.ToString("dd-mm-yyyy HH:mm:ss"), // eu + _ => when.ToString("yyyy-MM-dd HH:mm:ss"), // jp(0), cn(3), kr(4), and other possible errorneous cases + }; } /// Formats an instance of as a localized relative time.