Translate phase 1

This commit is contained in:
2025-09-21 17:01:12 +02:00
parent 0808266887
commit 6d8a8476b4
30 changed files with 2763 additions and 749 deletions

View File

@@ -2,6 +2,7 @@
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.Services;
using Dalamud.Interface;
using MareSynchronos.MareConfiguration;
using MareSynchronos.MareConfiguration.Configurations;
using MareSynchronos.PlayerData.Pairs;
@@ -10,11 +11,14 @@ using MareSynchronos.WebAPI;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System.Runtime.InteropServices;
using MareSynchronos.Localization;
using System.Globalization;
namespace MareSynchronos.UI;
public sealed class DtrEntry : IDisposable, IHostedService
{
public const string DefaultGlyph = "\u25CB";
private enum DtrStyle
{
Default,
@@ -44,6 +48,13 @@ public sealed class DtrEntry : IDisposable, IHostedService
private string? _tooltip;
private Colors _colors;
private static string L(string key, string fallback, params object[] args)
{
var safeArgs = args ?? Array.Empty<object>();
return LocalizationService.Instance?.GetString(key, fallback, safeArgs)
?? string.Format(CultureInfo.CurrentCulture, fallback, safeArgs);
}
public DtrEntry(ILogger<DtrEntry> logger, IDtrBar dtrBar, MareConfigService configService, MareMediator mareMediator, PairManager pairManager, ApiController apiController)
{
_logger = logger;
@@ -104,7 +115,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
private IDtrBarEntry CreateEntry()
{
_logger.LogTrace("Creating new DtrBar entry");
var entry = _dtrBar.Get("Umbra");
var entry = _dtrBar.Get(L("DtrEntry.EntryName", "Umbra"));
entry.OnClick = _ => _mareMediator.Publish(new UiToggleMessage(typeof(CompactUi)));
return entry;
@@ -163,19 +174,20 @@ public sealed class DtrEntry : IDisposable, IHostedService
.Select(x => string.Format("{0}", _configService.Current.PreferNoteInDtrTooltip ? x.GetNoteOrName() : x.PlayerName));
}
tooltip = $"Umbra: Connected{Environment.NewLine}----------{Environment.NewLine}{string.Join(Environment.NewLine, visiblePairs)}";
var header = L("DtrEntry.Tooltip.Connected", "Umbra: Connected");
tooltip = header + Environment.NewLine + "----------" + Environment.NewLine + string.Join(Environment.NewLine, visiblePairs);
colors = _configService.Current.DtrColorsPairsInRange;
}
else
{
tooltip = "Umbra: Connected";
tooltip = L("DtrEntry.Tooltip.Connected", "Umbra: Connected");
colors = _configService.Current.DtrColorsDefault;
}
}
else
{
text = RenderDtrStyle(_configService.Current.DtrStyle, "\uE04C");
tooltip = "Umbra: Not Connected";
tooltip = L("DtrEntry.Tooltip.Disconnected", "Umbra: Not Connected");
colors = _configService.Current.DtrColorsNotConnected;
}
@@ -196,7 +208,8 @@ public sealed class DtrEntry : IDisposable, IHostedService
{
var style = (DtrStyle)styleNum;
return style switch {
return style switch
{
DtrStyle.Style1 => $"\xE039 {text}",
DtrStyle.Style2 => $"\xE0BC {text}",
DtrStyle.Style3 => $"\xE0BD {text}",
@@ -206,7 +219,7 @@ public sealed class DtrEntry : IDisposable, IHostedService
DtrStyle.Style7 => $"\xE05D {text}",
DtrStyle.Style8 => $"\xE03C{text}",
DtrStyle.Style9 => $"\xE040 {text} \xE041",
_ => $"\uE044 {text}"
_ => DefaultGlyph + " " + text
};
}