diff --git a/Content.Client/Administration/UI/Tabs/AdminTab/AdminShuttleWindow.xaml.cs b/Content.Client/Administration/UI/Tabs/AdminTab/AdminShuttleWindow.xaml.cs index fbd7c3dcf3..2e1f0ca66d 100644 --- a/Content.Client/Administration/UI/Tabs/AdminTab/AdminShuttleWindow.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/AdminTab/AdminShuttleWindow.xaml.cs @@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab private void CallShuttleTimeOnOnTextChanged(LineEdit.LineEditEventArgs obj) { var loc = IoCManager.Resolve(); - _callShuttleButton.Disabled = !TimeSpan.TryParseExact(obj.Text, Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out _); + _callShuttleButton.Disabled = !TimeSpan.TryParseExact(obj.Text, ContentLocalizationManager.TimeSpanMinutesFormats, loc.DefaultCulture, out _); _callShuttleButton.Command = $"callshuttle {obj.Text}"; } } diff --git a/Content.Server/Administration/Commands/ShuttleCommands.cs b/Content.Server/Administration/Commands/ShuttleCommands.cs index 84d8a125e0..5b0d39fd15 100644 --- a/Content.Server/Administration/Commands/ShuttleCommands.cs +++ b/Content.Server/Administration/Commands/ShuttleCommands.cs @@ -17,7 +17,7 @@ namespace Content.Server.Administration.Commands var loc = IoCManager.Resolve(); // ReSharper disable once ConvertIfStatementToSwitchStatement - if (args.Length == 1 && TimeSpan.TryParseExact(args[0], Localization.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan)) + if (args.Length == 1 && TimeSpan.TryParseExact(args[0], ContentLocalizationManager.TimeSpanMinutesFormats, loc.DefaultCulture, out var timeSpan)) { EntitySystem.Get().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false); } diff --git a/Content.Server/Cuffs/Components/HandcuffComponent.cs b/Content.Server/Cuffs/Components/HandcuffComponent.cs index a3bad7b3d4..efef7d4772 100644 --- a/Content.Server/Cuffs/Components/HandcuffComponent.cs +++ b/Content.Server/Cuffs/Components/HandcuffComponent.cs @@ -19,7 +19,7 @@ namespace Content.Server.Cuffs.Components { [Dependency] private readonly IEntityManager _entities = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; - + private string _brokenName = string.Empty; private string _brokenDesc = string.Empty; @@ -83,7 +83,7 @@ namespace Content.Server.Cuffs.Components /// The iconstate used for broken handcuffs /// [ViewVariables] - [DataField("brokenName")] + [DataField("brokenName", readOnly: true)] public string BrokenName { get => _brokenName; @@ -94,7 +94,7 @@ namespace Content.Server.Cuffs.Components /// The iconstate used for broken handcuffs /// [ViewVariables] - [DataField("brokenDesc")] + [DataField("brokenDesc", readOnly: true)] public string BrokenDesc { get => _brokenDesc; diff --git a/Content.Server/Storage/Components/SecretStashComponent.cs b/Content.Server/Storage/Components/SecretStashComponent.cs index 5876ab1adc..bf72fad58d 100644 --- a/Content.Server/Storage/Components/SecretStashComponent.cs +++ b/Content.Server/Storage/Components/SecretStashComponent.cs @@ -16,7 +16,7 @@ namespace Content.Server.Storage.Components public sealed class SecretStashComponent : Component { private string _secretPartName = string.Empty; - + /// /// Max item size that can be fitted into secret stash. /// @@ -27,7 +27,7 @@ namespace Content.Server.Storage.Components /// IC secret stash name. For example "the toilet cistern". /// If empty string, will replace it with entity name in init. /// - [ViewVariables] [DataField("secretPartName")] + [ViewVariables] [DataField("secretPartName", readOnly: true)] public string SecretPartName { get => _secretPartName; diff --git a/Content.Shared/Entry/EntryPoint.cs b/Content.Shared/Entry/EntryPoint.cs index f84392337c..105c11f7b8 100644 --- a/Content.Shared/Entry/EntryPoint.cs +++ b/Content.Shared/Entry/EntryPoint.cs @@ -21,8 +21,6 @@ namespace Content.Shared.Entry { IoCManager.InjectDependencies(this); SharedContentIoC.Register(); - - Localization.Init(); } public override void Init() @@ -34,6 +32,7 @@ namespace Content.Shared.Entry base.PostInit(); InitTileDefinitions(); + IoCManager.Resolve().Initialize(); IoCManager.Resolve().Initialize(); var configMan = IoCManager.Resolve(); diff --git a/Content.Shared/IoC/SharedContentIoC.cs b/Content.Shared/IoC/SharedContentIoC.cs index 1df6996c21..c20cdbc111 100644 --- a/Content.Shared/IoC/SharedContentIoC.cs +++ b/Content.Shared/IoC/SharedContentIoC.cs @@ -1,4 +1,5 @@ using Content.Shared.Humanoid.Markings; +using Content.Shared.Localizations; namespace Content.Shared.IoC { @@ -7,6 +8,7 @@ namespace Content.Shared.IoC public static void Register() { IoCManager.Register(); + IoCManager.Register(); } } } diff --git a/Content.Shared/Localizations/Localization.cs b/Content.Shared/Localizations/ContentLocalizationManager.cs similarity index 84% rename from Content.Shared/Localizations/Localization.cs rename to Content.Shared/Localizations/ContentLocalizationManager.cs index 64c73c4348..4becb5d76b 100644 --- a/Content.Shared/Localizations/Localization.cs +++ b/Content.Shared/Localizations/ContentLocalizationManager.cs @@ -1,10 +1,12 @@ using System.Globalization; -using Robust.Shared.ContentPack; namespace Content.Shared.Localizations { - public static class Localization + public sealed class ContentLocalizationManager { + [Dependency] private readonly ILocalizationManager _loc = default!; + [Dependency] private readonly IEntityManager _ent = default!; + // If you want to change your codebase's language, do it here. private const string Culture = "en-US"; @@ -19,20 +21,17 @@ namespace Content.Shared.Localizations @"mm" }; - public static void Init() + public void Initialize() { - var loc = IoCManager.Resolve(); - var res = IoCManager.Resolve(); - var culture = new CultureInfo(Culture); - loc.LoadCulture(culture); - loc.AddFunction(culture, "PRESSURE", FormatPressure); - loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts); - loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules); - loc.AddFunction(culture, "UNITS", FormatUnits); - loc.AddFunction(culture, "TOSTRING", args => FormatToString(culture, args)); - loc.AddFunction(culture, "LOC", FormatLoc); + _loc.LoadCulture(culture); + _loc.AddFunction(culture, "PRESSURE", FormatPressure); + _loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts); + _loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules); + _loc.AddFunction(culture, "UNITS", FormatUnits); + _loc.AddFunction(culture, "TOSTRING", args => FormatToString(culture, args)); + _loc.AddFunction(culture, "LOC", FormatLoc); } private static ILocValue FormatLoc(LocArgs args) @@ -114,7 +113,7 @@ namespace Content.Shared.Localizations // Before anyone complains about "{"+"${...}", at least it's better than MS's approach... // https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-formatting#escaping-braces - // + // // Note that the closing brace isn't replaced so that format specifiers can be applied. var res = String.Format( fmtstr.Replace("{UNIT", "{" + $"{fargs.Length - 1}"), diff --git a/Resources/Locale/en-US/_lib.ftl b/Resources/Locale/en-US/_lib.ftl index b2e858b452..7c2befa7a9 100644 --- a/Resources/Locale/en-US/_lib.ftl +++ b/Resources/Locale/en-US/_lib.ftl @@ -31,61 +31,3 @@ zzzz-fmt-power-joules = { TOSTRING($divided, "G3") } { $places -> [4] TJ *[5] ??? } - -# Used internally by the THE() function. -zzzz-the = { PROPER($ent) -> - *[false] the { $ent } - [true] { $ent } - } - -# Used internally by the SUBJECT() function. -zzzz-subject-pronoun = { GENDER($ent) -> - [male] he - [female] she - [epicene] they - *[neuter] it - } - -# Used internally by the OBJECT() function. -zzzz-object-pronoun = { GENDER($ent) -> - [male] him - [female] her - [epicene] them - *[neuter] it - } - -# Used internally by the POSS-PRONOUN() function. -zzzz-possessive-pronoun = { GENDER($ent) -> - [male] his - [female] hers - [epicene] theirs - *[neuter] its - } - -# Used internally by the POSS-ADJ() function. -zzzz-possessive-adjective = { GENDER($ent) -> - [male] his - [female] her - [epicene] their - *[neuter] its - } - -# Used internally by the REFLEXIVE() function. -zzzz-reflexive-pronoun = { GENDER($ent) -> - [male] himself - [female] herself - [epicene] themselves - *[neuter] itself - } - -# Used internally by the CONJUGATE-BE() function. -zzzz-conjugate-be = { GENDER($ent) -> - [epicene] are - *[other] is - } - -# Used internally by the CONJUGATE-HAVE() function. -zzzz-conjugate-have = { GENDER($ent) -> - [epicene] have - *[other] has - }