localization support to air alarms, wire panels and more (#39307)

* Add localization to the air alarms, wire panels, network configurator list menu and loadout window

* delete unused

* redo gas localization, delete unused

* removed the extra key

* Moved and renamed air-alarm-ui-thresholds-gas-name

* Moved localization to the XAML

* Use existing strings for gas names

* it just works

* Rename _atmosphereSystem in ScrubberControl.xaml.cs

_atmosphereSystem -> atmosphereSystem

* Rename _atmosphereSystem in SensorInfo.xaml.cs

_atmosphereSystem -> atmosphereSystem
This commit is contained in:
Ser11y
2025-08-05 18:13:04 +03:00
committed by GitHub
parent 36967f3e7d
commit d7f8614c35
13 changed files with 135 additions and 56 deletions

View File

@@ -59,7 +59,7 @@ public sealed partial class PumpControl : BoxContainer
foreach (var value in Enum.GetValues<VentPumpDirection>()) foreach (var value in Enum.GetValues<VentPumpDirection>())
{ {
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value); _pumpDirection.AddItem(Loc.GetString($"air-alarm-ui-pump-direction-{value.ToString().ToLower()}"), (int) value);
} }
_pumpDirection.SelectId((int) _data.PumpDirection); _pumpDirection.SelectId((int) _data.PumpDirection);
@@ -72,7 +72,7 @@ public sealed partial class PumpControl : BoxContainer
foreach (var value in Enum.GetValues<VentPressureBound>()) foreach (var value in Enum.GetValues<VentPressureBound>())
{ {
_pressureCheck.AddItem(Loc.GetString($"{value}"), (int) value); _pressureCheck.AddItem(Loc.GetString($"air-alarm-ui-pressure-bound-{value.ToString().ToLower()}"), (int) value);
} }
_pressureCheck.SelectId((int) _data.PressureChecks); _pressureCheck.SelectId((int) _data.PressureChecks);

View File

@@ -27,7 +27,7 @@
</BoxContainer> </BoxContainer>
<!-- Lower row: every single gas --> <!-- Lower row: every single gas -->
<Collapsible Margin="2 2 2 2"> <Collapsible Margin="2 2 2 2">
<CollapsibleHeading Title="Gas filters" /> <CollapsibleHeading Title="{Loc 'air-alarm-ui-widget-gas-filters'}" />
<CollapsibleBody Margin="20 0 0 0"> <CollapsibleBody Margin="20 0 0 0">
<BoxContainer Orientation="Vertical"> <BoxContainer Orientation="Vertical">
<BoxContainer Margin="2"> <BoxContainer Margin="2">

View File

@@ -1,15 +1,21 @@
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.EntitySystems;
using Content.Shared.Atmos.Monitor.Components; using Content.Shared.Atmos.Monitor.Components;
using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Piping.Unary.Components;
using Content.Shared.Atmos.Prototypes;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client.Atmos.Monitor.UI.Widgets; namespace Content.Client.Atmos.Monitor.UI.Widgets;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class ScrubberControl : BoxContainer public sealed partial class ScrubberControl : BoxContainer
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
private GasVentScrubberData _data; private GasVentScrubberData _data;
private string _address; private string _address;
@@ -30,6 +36,10 @@ public sealed partial class ScrubberControl : BoxContainer
public ScrubberControl(GasVentScrubberData data, string address) public ScrubberControl(GasVentScrubberData data, string address)
{ {
IoCManager.InjectDependencies(this);
var atmosphereSystem = _entMan.System<SharedAtmosphereSystem>();
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
Name = address; Name = address;
@@ -63,7 +73,7 @@ public sealed partial class ScrubberControl : BoxContainer
foreach (var value in Enum.GetValues<ScrubberPumpDirection>()) foreach (var value in Enum.GetValues<ScrubberPumpDirection>())
{ {
_pumpDirection.AddItem(Loc.GetString($"{value}"), (int) value); _pumpDirection.AddItem(Loc.GetString($"air-alarm-ui-pump-direction-{value.ToString().ToLower()}"), (int) value);
} }
_pumpDirection.SelectId((int) _data.PumpDirection); _pumpDirection.SelectId((int) _data.PumpDirection);
@@ -95,10 +105,13 @@ public sealed partial class ScrubberControl : BoxContainer
foreach (var value in allGases) foreach (var value in allGases)
{ {
ProtoId<GasPrototype> gasProtoId = atmosphereSystem.GetGas(value);
var gasName = _prototypeManager.Index(gasProtoId).Name;
var gasButton = new Button var gasButton = new Button
{ {
Name = value.ToString(), Name = value.ToString(),
Text = Loc.GetString($"{value}"), Text = Loc.GetString(gasName),
ToggleMode = true, ToggleMode = true,
HorizontalExpand = true, HorizontalExpand = true,
Pressed = _data.FilterGases.Contains(value) Pressed = _data.FilterGases.Contains(value)

View File

@@ -1,16 +1,22 @@
using Content.Client.Message; using Content.Client.Message;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Atmos.EntitySystems;
using Content.Shared.Atmos.Monitor; using Content.Shared.Atmos.Monitor;
using Content.Shared.Atmos.Prototypes;
using Content.Shared.Temperature; using Content.Shared.Temperature;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client.Atmos.Monitor.UI.Widgets; namespace Content.Client.Atmos.Monitor.UI.Widgets;
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class SensorInfo : BoxContainer public sealed partial class SensorInfo : BoxContainer
{ {
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
public Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? OnThresholdUpdate; public Action<string, AtmosMonitorThresholdType, AtmosAlarmThreshold, Gas?>? OnThresholdUpdate;
public event Action<AtmosSensorData>? SensorDataCopied; public event Action<AtmosSensorData>? SensorDataCopied;
private string _address; private string _address;
@@ -23,6 +29,9 @@ public sealed partial class SensorInfo : BoxContainer
public SensorInfo(AtmosSensorData data, string address) public SensorInfo(AtmosSensorData data, string address)
{ {
IoCManager.InjectDependencies(this);
var atmosphereSystem = _entMan.System<SharedAtmosphereSystem>();
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
_address = address; _address = address;
@@ -45,8 +54,12 @@ public sealed partial class SensorInfo : BoxContainer
var label = new RichTextLabel(); var label = new RichTextLabel();
var fractionGas = amount / data.TotalMoles; var fractionGas = amount / data.TotalMoles;
ProtoId<GasPrototype> gasProtoId = atmosphereSystem.GetGas(gas);
var gasName = _prototypeManager.Index(gasProtoId).Name;
label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator", label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator",
("gas", $"{gas}"), ("gas", Loc.GetString(gasName)),
("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])), ("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])),
("amount", $"{amount:0.####}"), ("amount", $"{amount:0.####}"),
("percentage", $"{(100 * fractionGas):0.##}"))); ("percentage", $"{(100 * fractionGas):0.##}")));
@@ -54,7 +67,7 @@ public sealed partial class SensorInfo : BoxContainer
_gasLabels.Add(gas, label); _gasLabels.Add(gas, label);
var threshold = data.GasThresholds[gas]; var threshold = data.GasThresholds[gas];
var gasThresholdControl = new ThresholdControl(Loc.GetString($"air-alarm-ui-thresholds-gas-title", ("gas", $"{gas}")), threshold, AtmosMonitorThresholdType.Gas, gas, 100); var gasThresholdControl = new ThresholdControl(Loc.GetString($"air-alarm-ui-thresholds-gas-title"), threshold, AtmosMonitorThresholdType.Gas, gas, 100);
gasThresholdControl.Margin = new Thickness(20, 2, 2, 2); gasThresholdControl.Margin = new Thickness(20, 2, 2, 2);
gasThresholdControl.ThresholdDataChanged += (type, alarmThreshold, arg3) => gasThresholdControl.ThresholdDataChanged += (type, alarmThreshold, arg3) =>
{ {
@@ -90,6 +103,9 @@ public sealed partial class SensorInfo : BoxContainer
public void ChangeData(AtmosSensorData data) public void ChangeData(AtmosSensorData data)
{ {
IoCManager.InjectDependencies(this);
var atmosphereSystem = _entMan.System<SharedAtmosphereSystem>();
SensorAddress.Title = Loc.GetString("air-alarm-ui-window-listing-title", ("address", _address), ("state", data.AlarmState)); SensorAddress.Title = Loc.GetString("air-alarm-ui-window-listing-title", ("address", _address), ("state", data.AlarmState));
AlarmStateLabel.SetMarkup(Loc.GetString("air-alarm-ui-window-alarm-state-indicator", AlarmStateLabel.SetMarkup(Loc.GetString("air-alarm-ui-window-alarm-state-indicator",
@@ -112,8 +128,12 @@ public sealed partial class SensorInfo : BoxContainer
} }
var fractionGas = amount / data.TotalMoles; var fractionGas = amount / data.TotalMoles;
ProtoId<GasPrototype> gasProtoId = atmosphereSystem.GetGas(gas);
var gasName = _prototypeManager.Index(gasProtoId).Name;
label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator", label.SetMarkup(Loc.GetString("air-alarm-ui-gases-indicator",
("gas", $"{gas}"), ("gas", Loc.GetString(gasName)),
("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])), ("color", AirAlarmWindow.ColorForThreshold(fractionGas, data.GasThresholds[gas])),
("amount", $"{amount:0.####}"), ("amount", $"{amount:0.####}"),
("percentage", $"{(100 * fractionGas):0.##}"))); ("percentage", $"{(100 * fractionGas):0.##}")));

View File

@@ -2,6 +2,6 @@
HorizontalExpand="True" Orientation="Vertical" HorizontalExpand="True" Orientation="Vertical"
Margin = "20 0 0 0" MinSize="160 0" > Margin = "20 0 0 0" MinSize="160 0" >
<Label Name="CBoundLabel" HorizontalAlignment="Center" /> <Label Name="CBoundLabel" HorizontalAlignment="Center" />
<CheckBox Name="CBoundEnabled" HorizontalAlignment="Center" Text="{Loc 'Enable'}" Pressed="True" /> <CheckBox Name="CBoundEnabled" HorizontalAlignment="Center" Text="{Loc 'air-alarm-ui-widget-enable'}" Pressed="True" />
<FloatSpinBox Name="CSpinner" /> <FloatSpinBox Name="CSpinner" />
</BoxContainer> </BoxContainer>

View File

@@ -6,7 +6,7 @@
<CollapsibleBody Margin="20 0 0 0"> <CollapsibleBody Margin="20 0 0 0">
<BoxContainer Orientation="Vertical"> <BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal"> <BoxContainer Orientation="Horizontal">
<CheckBox Name="CEnabled" Text="{Loc 'Enabled'}" /> <CheckBox Name="CEnabled" Text="{Loc 'air-alarm-ui-widget-enable'}" />
</BoxContainer> </BoxContainer>
<!-- Upper row: Danger bounds --> <!-- Upper row: Danger bounds -->
<BoxContainer Name="CDangerBounds" Orientation="Horizontal" Margin="0 0 0 2"/> <BoxContainer Name="CDangerBounds" Orientation="Horizontal" Margin="0 0 0 2"/>

View File

@@ -1020,7 +1020,7 @@ namespace Content.Client.Lobby.UI
_loadoutWindow = new LoadoutWindow(Profile, roleLoadout, roleLoadoutProto, _playerManager.LocalSession, collection) _loadoutWindow = new LoadoutWindow(Profile, roleLoadout, roleLoadoutProto, _playerManager.LocalSession, collection)
{ {
Title = jobProto?.ID + "-loadout", Title = Loc.GetString("loadout-window-title-loadout", ("job", $"{jobProto?.LocalizedName}")),
}; };
// Refresh the buttons etc. // Refresh the buttons etc.

View File

@@ -5,15 +5,15 @@
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True"> <BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<networkConfigurator:NetworkConfiguratorDeviceList Name="DeviceList" MinHeight="500" /> <networkConfigurator:NetworkConfiguratorDeviceList Name="DeviceList" MinHeight="500" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 8 8 1"> <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 8 8 1">
<Button Name="Set" Text="Set" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-set'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> <Button Name="Set" Text="{Loc 'network-configurator-text-set'}" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-set'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>
<Button Name="Add" Text="Add" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-add'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> <Button Name="Add" Text="{Loc 'network-configurator-text-add'}" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-add'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>
<!-- Edit might not be needed --> <!-- Edit might not be needed -->
<!--<Button Name="Edit" Text="Edit" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-edit'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>--> <!--<Button Name="Edit" Text="Edit" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-edit'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>-->
<Button Name="Clear" Text="Clear" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-clear'}" HorizontalExpand="True"/> <Button Name="Clear" Text="{Loc 'network-configurator-text-clear'}" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-clear'}" HorizontalExpand="True"/>
</BoxContainer> </BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 0 8 8"> <BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="8 0 8 8">
<Button Name="Copy" Text="Copy" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-copy'}" HorizontalExpand="True" StyleClasses="OpenRight"/> <Button Name="Copy" Text="{Loc 'network-configurator-text-copy'}" Access="Public" ToolTip="{Loc 'network-configurator-tooltip-copy'}" HorizontalExpand="True" StyleClasses="OpenRight"/>
<Button Name="Show" Text="Show" Access="Public" ToggleMode="True" ToolTip="{Loc 'network-configurator-tooltip-show'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/> <Button Name="Show" Text="{Loc 'network-configurator-text-show'}" Access="Public" ToggleMode="True" ToolTip="{Loc 'network-configurator-tooltip-show'}" HorizontalExpand="True" StyleClasses="ButtonSquare"/>
</BoxContainer> </BoxContainer>
<Label Name="Count" StyleClasses="LabelSubText" HorizontalAlignment="Right" Margin="0 0 12 8"/> <Label Name="Count" StyleClasses="LabelSubText" HorizontalAlignment="Right" Margin="0 0 12 8"/>
</BoxContainer> </BoxContainer>

View File

@@ -209,22 +209,8 @@ namespace Content.Shared.Wires
{ {
public static string Name(this WireColor color) public static string Name(this WireColor color)
{ {
return Loc.GetString(color switch var colorName = Enum.GetName(color) ?? throw new InvalidOperationException();
{ return Loc.GetString($"wire-name-color-{colorName.ToLower()}");
WireColor.Red => "Red",
WireColor.Blue => "Blue",
WireColor.Green => "Green",
WireColor.Orange => "Orange",
WireColor.Brown => "Brown",
WireColor.Gold => "Gold",
WireColor.Gray => "Gray",
WireColor.Cyan => "Cyan",
WireColor.Navy => "Navy",
WireColor.Purple => "Purple",
WireColor.Pink => "Pink",
WireColor.Fuchsia => "Fuchsia",
_ => throw new InvalidOperationException()
});
} }
public static Color ColorValue(this WireColor color) public static Color ColorValue(this WireColor color)
@@ -251,30 +237,30 @@ namespace Content.Shared.Wires
{ {
return Loc.GetString(letter switch return Loc.GetString(letter switch
{ {
WireLetter.α => "Alpha", WireLetter.α => "wire-letter-name-alpha",
WireLetter.β => "Beta", WireLetter.β => "wire-letter-name-beta",
WireLetter.γ => "Gamma", WireLetter.γ => "wire-letter-name-gamma",
WireLetter.δ => "Delta", WireLetter.δ => "wire-letter-name-delta",
WireLetter.ε => "Epsilon", WireLetter.ε => "wire-letter-name-epsilon",
WireLetter.ζ => "Zeta", WireLetter.ζ => "wire-letter-name-zeta ",
WireLetter.η => "Eta", WireLetter.η => "wire-letter-name-eta",
WireLetter.θ => "Theta", WireLetter.θ => "wire-letter-name-theta",
WireLetter.ι => "Iota", WireLetter.ι => "wire-letter-name-iota",
WireLetter.κ => "Kappa", WireLetter.κ => "wire-letter-name-kappa",
WireLetter.λ => "Lambda", WireLetter.λ => "wire-letter-name-lambda",
WireLetter.μ => "Mu", WireLetter.μ => "wire-letter-name-mu",
WireLetter.ν => "Nu", WireLetter.ν => "wire-letter-name-nu",
WireLetter.ξ => "Xi", WireLetter.ξ => "wire-letter-name-xi",
WireLetter.ο => "Omicron", WireLetter.ο => "wire-letter-name-omicron",
WireLetter.π => "Pi", WireLetter.π => "wire-letter-name-pi",
WireLetter.ρ => "Rho", WireLetter.ρ => "wire-letter-name-rho",
WireLetter.σ => "Sigma", WireLetter.σ => "wire-letter-name-sigma",
WireLetter.τ => "Tau", WireLetter.τ => "wire-letter-name-tau",
WireLetter.υ => "Upsilon", WireLetter.υ => "wire-letter-name-upsilon",
WireLetter.φ => "Phi", WireLetter.φ => "wire-letter-name-phi",
WireLetter.χ => "Chi", WireLetter.χ => "wire-letter-name-chi",
WireLetter.ψ => "Psi", WireLetter.ψ => "wire-letter-name-psi",
WireLetter.ω => "Omega", WireLetter.ω => "wire-letter-name-omega",
_ => throw new InvalidOperationException() _ => throw new InvalidOperationException()
}); });
} }

View File

@@ -47,6 +47,18 @@ air-alarm-ui-mode-fill = Fill
air-alarm-ui-mode-panic = Panic air-alarm-ui-mode-panic = Panic
air-alarm-ui-mode-none = None air-alarm-ui-mode-none = None
air-alarm-ui-pump-direction-siphoning = Siphoning
air-alarm-ui-pump-direction-scrubbing = Scrubbing
air-alarm-ui-pump-direction-releasing = Releasing
air-alarm-ui-pressure-bound-nobound = No Bound
air-alarm-ui-pressure-bound-internalbound = Internal Bound
air-alarm-ui-pressure-bound-externalbound = External Bound
air-alarm-ui-pressure-bound-both = Both
air-alarm-ui-widget-gas-filters = Gas Filters
## Widgets ## Widgets
### General ### General

View File

@@ -26,6 +26,12 @@ network-configurator-title-device-configuration = Device Configuration
network-configurator-ui-clear-button = Clear network-configurator-ui-clear-button = Clear
network-configurator-ui-count-label = {$count} Devices network-configurator-ui-count-label = {$count} Devices
network-configurator-text-set = Set
network-configurator-text-add = Add
network-configurator-text-clear = Clear
network-configurator-text-copy = Copy
network-configurator-text-show = Show
# tooltips # tooltips
network-configurator-tooltip-set = Sets targets device list network-configurator-tooltip-set = Sets targets device list
network-configurator-tooltip-add = Adds to targets device list network-configurator-tooltip-add = Adds to targets device list

View File

@@ -1,2 +1,3 @@
loadout-window = Loadout loadout-window = Loadout
loadout-none = None loadout-none = None
loadout-window-title-loadout = { $job } loadout

View File

@@ -1,2 +1,43 @@
wires-panel-component-on-examine-open = The [color=lightgray]maintenance panel[/color] is [color=red]open[/color]. wires-panel-component-on-examine-open = The [color=lightgray]maintenance panel[/color] is [color=red]open[/color].
wires-panel-component-on-examine-closed = The [color=lightgray]maintenance panel[/color] is [color=darkgreen]closed[/color]. wires-panel-component-on-examine-closed = The [color=lightgray]maintenance panel[/color] is [color=darkgreen]closed[/color].
# wire colors
wire-name-color-red = Red
wire-name-color-blue = Blue
wire-name-color-green = Green
wire-name-color-orange = Orange
wire-name-color-brown = Brown
wire-name-color-gold = Gold
wire-name-color-gray = Gray
wire-name-color-cyan = Cyan
wire-name-color-navy = Navy
wire-name-color-purple = Purple
wire-name-color-pink = Pink
wire-name-color-fuchsia = Fuchsia
# letter names
wire-letter-name-alpha = Alpha
wire-letter-name-beta = Beta
wire-letter-name-gamma = Gamma
wire-letter-name-delta = Delta
wire-letter-name-epsilon = Epsilon
wire-letter-name-zeta = Zeta
wire-letter-name-eta = Eta
wire-letter-name-theta = Theta
wire-letter-name-iota = Iota
wire-letter-name-kappa = Kappa
wire-letter-name-lambda = Lambda
wire-letter-name-mu = Mu
wire-letter-name-nu = Nu
wire-letter-name-xi = Xi
wire-letter-name-omicron = Omicron
wire-letter-name-pi = Pi
wire-letter-name-rho = Rho
wire-letter-name-sigma = Sigma
wire-letter-name-tau = Tau
wire-letter-name-upsilon = Upsilon
wire-letter-name-phi = Phi
wire-letter-name-chi = Chi
wire-letter-name-psi = Psi
wire-letter-name-omega = Omega