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

@@ -5,12 +5,15 @@ using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using MareSynchronos.API.Data.Extensions;
using MareSynchronos.API.Dto.User;
using MareSynchronos.Localization;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
using MareSynchronos.UI.Handlers;
using MareSynchronos.WebAPI;
using System.Numerics;
using System.Globalization;
using System;
namespace MareSynchronos.UI.Components;
@@ -21,6 +24,13 @@ public class DrawUserPair : DrawPairBase
private readonly SelectGroupForPairUi _selectGroupForPairUi;
private readonly CharaDataManager _charaDataManager;
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 DrawUserPair(string id, Pair entry, UidDisplayHandler displayHandler, ApiController apiController,
MareMediator mareMediator, SelectGroupForPairUi selectGroupForPairUi,
UiSharedService uiSharedService, CharaDataManager charaDataManager)
@@ -47,8 +57,8 @@ public class DrawUserPair : DrawPairBase
UiSharedService.ColorText(FontAwesomeIcon.Moon.ToIconString(), online ? Violet : offlineGrey);
ImGui.PopFont();
UiSharedService.AttachToolTip(online
? "User is online"
: "User is offline");
? L("UserPair.Status.Online", "User is online")
: L("UserPair.Status.Offline", "User is offline"));
if (!(_pair.UserPair!.OwnPermissions.IsPaired() && _pair.UserPair!.OtherPermissions.IsPaired()))
{
ImGui.SameLine();
@@ -56,7 +66,7 @@ public class DrawUserPair : DrawPairBase
ImGui.PushFont(UiBuilder.IconFont);
UiSharedService.ColorText(FontAwesomeIcon.ArrowUp.ToIconString(), ImGuiColors.DalamudRed);
ImGui.PopFont();
UiSharedService.AttachToolTip(_pair.UserData.AliasOrUID + " has not added you back");
UiSharedService.AttachToolTip(L("UserPair.Tooltip.NotAddedBack", "{0} has not added you back", _pair.UserData.AliasOrUID));
}
else if (_pair.UserPair!.OwnPermissions.IsPaused() || _pair.UserPair!.OtherPermissions.IsPaused())
{
@@ -65,7 +75,7 @@ public class DrawUserPair : DrawPairBase
ImGui.PushFont(UiBuilder.IconFont);
UiSharedService.ColorText(FontAwesomeIcon.PauseCircle.ToIconString(), ImGuiColors.DalamudYellow);
ImGui.PopFont();
UiSharedService.AttachToolTip("Pairing with " + _pair.UserData.AliasOrUID + " is paused");
UiSharedService.AttachToolTip(L("UserPair.Tooltip.Paused", "Pairing with {0} is paused", _pair.UserData.AliasOrUID));
}
if (_pair is { IsOnline: true, IsVisible: true })
{
@@ -78,20 +88,23 @@ public class DrawUserPair : DrawPairBase
_mediator.Publish(new TargetPairMessage(_pair));
}
ImGui.PopFont();
var visibleTooltip = _pair.UserData.AliasOrUID + " is visible: " + _pair.PlayerName! + Environment.NewLine + "Click to target this player";
var visibleTooltip = L("UserPair.Tooltip.Visible", "{0} is visible: {1}\nClick to target this player", _pair.UserData.AliasOrUID, _pair.PlayerName!);
if (_pair.LastAppliedDataBytes >= 0)
{
visibleTooltip += UiSharedService.TooltipSeparator;
visibleTooltip += ((!_pair.IsVisible) ? "(Last) " : string.Empty) + "Mods Info" + Environment.NewLine;
visibleTooltip += "Files Size: " + UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true);
visibleTooltip += (!_pair.IsVisible ? L("UserPair.Tooltip.Visible.LastPrefix", "(Last) ") : string.Empty)
+ L("UserPair.Tooltip.Visible.ModsInfo", "Mods Info") + Environment.NewLine;
visibleTooltip += L("UserPair.Tooltip.Visible.FilesSize", "Files Size: {0}", UiSharedService.ByteToString(_pair.LastAppliedDataBytes, true));
if (_pair.LastAppliedApproximateVRAMBytes >= 0)
{
visibleTooltip += Environment.NewLine + "Approx. VRAM Usage: " + UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true);
visibleTooltip += Environment.NewLine + L("UserPair.Tooltip.Visible.Vram", "Approx. VRAM Usage: {0}", UiSharedService.ByteToString(_pair.LastAppliedApproximateVRAMBytes, true));
}
if (_pair.LastAppliedDataTris >= 0)
{
visibleTooltip += Environment.NewLine + "Triangle Count (excl. Vanilla): "
+ (_pair.LastAppliedDataTris > 1000 ? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'") : _pair.LastAppliedDataTris);
var trisValue = _pair.LastAppliedDataTris > 1000
? (_pair.LastAppliedDataTris / 1000d).ToString("0.0'k'", CultureInfo.CurrentCulture)
: _pair.LastAppliedDataTris.ToString(CultureInfo.CurrentCulture);
visibleTooltip += Environment.NewLine + L("UserPair.Tooltip.Visible.Tris", "Triangle Count (excl. Vanilla): {0}", trisValue);
}
}
@@ -136,8 +149,8 @@ public class DrawUserPair : DrawPairBase
_ = _apiController.UserSetPairPermissions(new(_pair.UserData, perm));
}
UiSharedService.AttachToolTip(!_pair.UserPair!.OwnPermissions.IsPaused()
? "Pause pairing with " + entryUID
: "Resume pairing with " + entryUID);
? L("UserPair.Tooltip.Pause", "Pause pairing with {0}", entryUID)
: L("UserPair.Tooltip.Resume", "Resume pairing with {0}", entryUID));
var individualSoundsDisabled = (_pair.UserPair?.OwnPermissions.IsDisableSounds() ?? false) || (_pair.UserPair?.OtherPermissions.IsDisableSounds() ?? false);
@@ -158,39 +171,57 @@ public class DrawUserPair : DrawPairBase
{
ImGui.BeginTooltip();
ImGui.TextUnformatted("Individual User permissions");
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Header", "Individual user permissions"));
if (individualSoundsDisabled)
{
var userSoundsText = "Sound sync disabled with " + _pair.UserData.AliasOrUID;
var userSoundsText = L("UserPair.Tooltip.Permission.Sound", "Sound sync disabled with {0}", _pair.UserData.AliasOrUID);
_uiSharedService.IconText(FontAwesomeIcon.VolumeOff);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted(userSoundsText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableSounds() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableSounds() ? "Disabled" : "Enabled"));
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableSounds()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableSounds()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
}
if (individualAnimDisabled)
{
var userAnimText = "Animation sync disabled with " + _pair.UserData.AliasOrUID;
var userAnimText = L("UserPair.Tooltip.Permission.Animation", "Animation sync disabled with {0}", _pair.UserData.AliasOrUID);
_uiSharedService.IconText(FontAwesomeIcon.Stop);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted(userAnimText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableAnimations() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableAnimations() ? "Disabled" : "Enabled"));
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableAnimations()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableAnimations()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
}
if (individualVFXDisabled)
{
var userVFXText = "VFX sync disabled with " + _pair.UserData.AliasOrUID;
var userVFXText = L("UserPair.Tooltip.Permission.Vfx", "VFX sync disabled with {0}", _pair.UserData.AliasOrUID);
_uiSharedService.IconText(FontAwesomeIcon.Circle);
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted(userVFXText);
ImGui.NewLine();
ImGui.SameLine(40 * ImGuiHelpers.GlobalScale);
ImGui.TextUnformatted("You: " + (_pair.UserPair!.OwnPermissions.IsDisableVFX() ? "Disabled" : "Enabled") + ", They: " + (_pair.UserPair!.OtherPermissions.IsDisableVFX() ? "Disabled" : "Enabled"));
var youStatus = _pair.UserPair!.OwnPermissions.IsDisableVFX()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
var theyStatus = _pair.UserPair!.OtherPermissions.IsDisableVFX()
? L("UserPair.Tooltip.Permission.State.Disabled", "Disabled")
: L("UserPair.Tooltip.Permission.State.Enabled", "Enabled");
ImGui.TextUnformatted(L("UserPair.Tooltip.Permission.Status", "You: {0}, They: {1}", youStatus, theyStatus));
}
ImGui.EndTooltip();
@@ -205,8 +236,9 @@ public class DrawUserPair : DrawPairBase
ImGui.SameLine(rightSidePos);
_uiSharedService.IconText(icon);
UiSharedService.AttachToolTip($"This user has shared {sharedData.Count} Character Data Sets with you." + UiSharedService.TooltipSeparator
+ "Click to open the Character Data Hub and show the entries.");
UiSharedService.AttachToolTip(L("UserPair.Tooltip.SharedData", "This user has shared {0} Character Data Sets with you.", sharedData.Count)
+ UiSharedService.TooltipSeparator
+ L("UserPair.Tooltip.SharedData.OpenHub", "Click to open the Character Data Hub and show the entries."));
if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{
@@ -221,7 +253,7 @@ public class DrawUserPair : DrawPairBase
{
if (entry.IsVisible)
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, "Target player"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Eye, L("UserPair.Menu.Target", "Target player")))
{
_mediator.Publish(new TargetPairMessage(entry));
ImGui.CloseCurrentPopup();
@@ -229,44 +261,46 @@ public class DrawUserPair : DrawPairBase
}
if (!entry.IsPaused)
{
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, "Open Profile"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.User, L("UserPair.Menu.OpenProfile", "Open Profile")))
{
_displayHandler.OpenProfile(entry);
ImGui.CloseCurrentPopup();
}
UiSharedService.AttachToolTip("Opens the profile for this user in a new window");
UiSharedService.AttachToolTip(L("UserPair.Menu.OpenProfile.Tooltip", "Opens the profile for this user in a new window"));
}
if (entry.IsVisible)
{
#if DEBUG
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, "Open Analysis"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PersonCircleQuestion, L("UserPair.Menu.OpenAnalysis", "Open Analysis")))
{
_displayHandler.OpenAnalysis(_pair);
ImGui.CloseCurrentPopup();
}
#endif
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, "Reload last data"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Sync, L("UserPair.Menu.ReloadData", "Reload last data")))
{
entry.ApplyLastReceivedData(forced: true);
ImGui.CloseCurrentPopup();
}
UiSharedService.AttachToolTip("This reapplies the last received character data to this character");
UiSharedService.AttachToolTip(L("UserPair.Menu.ReloadData.Tooltip", "This reapplies the last received character data to this character"));
}
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, "Cycle pause state"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.PlayCircle, L("UserPair.Menu.CyclePause", "Cycle pause state")))
{
_ = _apiController.CyclePause(entry.UserData);
ImGui.CloseCurrentPopup();
}
var entryUID = entry.UserData.AliasOrUID;
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, "Pair Groups"))
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Folder, L("UserPair.Menu.PairGroups", "Pair Groups")))
{
_selectGroupForPairUi.Open(entry);
}
UiSharedService.AttachToolTip("Choose pair groups for " + entryUID);
UiSharedService.AttachToolTip(L("UserPair.Menu.PairGroups.Tooltip", "Choose pair groups for {0}", entryUID));
var isDisableSounds = entry.UserPair!.OwnPermissions.IsDisableSounds();
string disableSoundsText = isDisableSounds ? "Enable sound sync" : "Disable sound sync";
string disableSoundsText = isDisableSounds
? L("UserPair.Menu.EnableSoundSync", "Enable sound sync")
: L("UserPair.Menu.DisableSoundSync", "Disable sound sync");
var disableSoundsIcon = isDisableSounds ? FontAwesomeIcon.VolumeUp : FontAwesomeIcon.VolumeMute;
if (_uiSharedService.IconTextButton(disableSoundsIcon, disableSoundsText))
{
@@ -276,7 +310,9 @@ public class DrawUserPair : DrawPairBase
}
var isDisableAnims = entry.UserPair!.OwnPermissions.IsDisableAnimations();
string disableAnimsText = isDisableAnims ? "Enable animation sync" : "Disable animation sync";
string disableAnimsText = isDisableAnims
? L("UserPair.Menu.EnableAnimationSync", "Enable animation sync")
: L("UserPair.Menu.DisableAnimationSync", "Disable animation sync");
var disableAnimsIcon = isDisableAnims ? FontAwesomeIcon.Running : FontAwesomeIcon.Stop;
if (_uiSharedService.IconTextButton(disableAnimsIcon, disableAnimsText))
{
@@ -286,7 +322,9 @@ public class DrawUserPair : DrawPairBase
}
var isDisableVFX = entry.UserPair!.OwnPermissions.IsDisableVFX();
string disableVFXText = isDisableVFX ? "Enable VFX sync" : "Disable VFX sync";
string disableVFXText = isDisableVFX
? L("UserPair.Menu.EnableVfxSync", "Enable VFX sync")
: L("UserPair.Menu.DisableVfxSync", "Disable VFX sync");
var disableVFXIcon = isDisableVFX ? FontAwesomeIcon.Sun : FontAwesomeIcon.Circle;
if (_uiSharedService.IconTextButton(disableVFXIcon, disableVFXText))
{
@@ -295,10 +333,10 @@ public class DrawUserPair : DrawPairBase
_ = _apiController.UserSetPairPermissions(new UserPermissionsDto(entry.UserData, permissions));
}
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, "Unpair Permanently") && UiSharedService.CtrlPressed())
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Trash, L("UserPair.Menu.Unpair", "Unpair Permanently")) && UiSharedService.CtrlPressed())
{
_ = _apiController.UserRemovePair(new(entry.UserData));
}
UiSharedService.AttachToolTip("Hold CTRL and click to unpair permanently from " + entryUID);
UiSharedService.AttachToolTip(L("UserPair.Menu.Unpair.Tooltip", "Hold CTRL and click to unpair permanently from {0}", entryUID));
}
}