Slight localization func cleanup (#11380)

This commit is contained in:
Kara
2022-10-18 19:51:18 -07:00
committed by GitHub
parent 592f135d92
commit 7ad867fa0f
8 changed files with 23 additions and 81 deletions

View File

@@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
private void CallShuttleTimeOnOnTextChanged(LineEdit.LineEditEventArgs obj) private void CallShuttleTimeOnOnTextChanged(LineEdit.LineEditEventArgs obj)
{ {
var loc = IoCManager.Resolve<ILocalizationManager>(); var loc = IoCManager.Resolve<ILocalizationManager>();
_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}"; _callShuttleButton.Command = $"callshuttle {obj.Text}";
} }
} }

View File

@@ -17,7 +17,7 @@ namespace Content.Server.Administration.Commands
var loc = IoCManager.Resolve<ILocalizationManager>(); var loc = IoCManager.Resolve<ILocalizationManager>();
// ReSharper disable once ConvertIfStatementToSwitchStatement // 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<RoundEndSystem>().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false); EntitySystem.Get<RoundEndSystem>().RequestRoundEnd(timeSpan, shell.Player?.AttachedEntity, false);
} }

View File

@@ -83,7 +83,7 @@ namespace Content.Server.Cuffs.Components
/// The iconstate used for broken handcuffs /// The iconstate used for broken handcuffs
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("brokenName")] [DataField("brokenName", readOnly: true)]
public string BrokenName public string BrokenName
{ {
get => _brokenName; get => _brokenName;
@@ -94,7 +94,7 @@ namespace Content.Server.Cuffs.Components
/// The iconstate used for broken handcuffs /// The iconstate used for broken handcuffs
/// </summary> /// </summary>
[ViewVariables] [ViewVariables]
[DataField("brokenDesc")] [DataField("brokenDesc", readOnly: true)]
public string BrokenDesc public string BrokenDesc
{ {
get => _brokenDesc; get => _brokenDesc;

View File

@@ -27,7 +27,7 @@ namespace Content.Server.Storage.Components
/// IC secret stash name. For example "the toilet cistern". /// IC secret stash name. For example "the toilet cistern".
/// If empty string, will replace it with entity name in init. /// If empty string, will replace it with entity name in init.
/// </summary> /// </summary>
[ViewVariables] [DataField("secretPartName")] [ViewVariables] [DataField("secretPartName", readOnly: true)]
public string SecretPartName public string SecretPartName
{ {
get => _secretPartName; get => _secretPartName;

View File

@@ -21,8 +21,6 @@ namespace Content.Shared.Entry
{ {
IoCManager.InjectDependencies(this); IoCManager.InjectDependencies(this);
SharedContentIoC.Register(); SharedContentIoC.Register();
Localization.Init();
} }
public override void Init() public override void Init()
@@ -34,6 +32,7 @@ namespace Content.Shared.Entry
base.PostInit(); base.PostInit();
InitTileDefinitions(); InitTileDefinitions();
IoCManager.Resolve<ContentLocalizationManager>().Initialize();
IoCManager.Resolve<MarkingManager>().Initialize(); IoCManager.Resolve<MarkingManager>().Initialize();
var configMan = IoCManager.Resolve<IConfigurationManager>(); var configMan = IoCManager.Resolve<IConfigurationManager>();

View File

@@ -1,4 +1,5 @@
using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Markings;
using Content.Shared.Localizations;
namespace Content.Shared.IoC namespace Content.Shared.IoC
{ {
@@ -7,6 +8,7 @@ namespace Content.Shared.IoC
public static void Register() public static void Register()
{ {
IoCManager.Register<MarkingManager, MarkingManager>(); IoCManager.Register<MarkingManager, MarkingManager>();
IoCManager.Register<ContentLocalizationManager, ContentLocalizationManager>();
} }
} }
} }

View File

@@ -1,10 +1,12 @@
using System.Globalization; using System.Globalization;
using Robust.Shared.ContentPack;
namespace Content.Shared.Localizations 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. // If you want to change your codebase's language, do it here.
private const string Culture = "en-US"; private const string Culture = "en-US";
@@ -19,20 +21,17 @@ namespace Content.Shared.Localizations
@"mm" @"mm"
}; };
public static void Init() public void Initialize()
{ {
var loc = IoCManager.Resolve<ILocalizationManager>();
var res = IoCManager.Resolve<IResourceManager>();
var culture = new CultureInfo(Culture); var culture = new CultureInfo(Culture);
loc.LoadCulture(culture); _loc.LoadCulture(culture);
loc.AddFunction(culture, "PRESSURE", FormatPressure); _loc.AddFunction(culture, "PRESSURE", FormatPressure);
loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts); _loc.AddFunction(culture, "POWERWATTS", FormatPowerWatts);
loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules); _loc.AddFunction(culture, "POWERJOULES", FormatPowerJoules);
loc.AddFunction(culture, "UNITS", FormatUnits); _loc.AddFunction(culture, "UNITS", FormatUnits);
loc.AddFunction(culture, "TOSTRING", args => FormatToString(culture, args)); _loc.AddFunction(culture, "TOSTRING", args => FormatToString(culture, args));
loc.AddFunction(culture, "LOC", FormatLoc); _loc.AddFunction(culture, "LOC", FormatLoc);
} }
private static ILocValue FormatLoc(LocArgs args) private static ILocValue FormatLoc(LocArgs args)

View File

@@ -31,61 +31,3 @@ zzzz-fmt-power-joules = { TOSTRING($divided, "G3") } { $places ->
[4] TJ [4] TJ
*[5] ??? *[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
}