Slight localization func cleanup (#11380)
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
private void CallShuttleTimeOnOnTextChanged(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
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}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Content.Server.Administration.Commands
|
||||
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
[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
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("brokenDesc")]
|
||||
[DataField("brokenDesc", readOnly: true)]
|
||||
public string BrokenDesc
|
||||
{
|
||||
get => _brokenDesc;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Content.Server.Storage.Components
|
||||
public sealed class SecretStashComponent : Component
|
||||
{
|
||||
private string _secretPartName = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Max item size that can be fitted into secret stash.
|
||||
/// </summary>
|
||||
@@ -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.
|
||||
/// </summary>
|
||||
[ViewVariables] [DataField("secretPartName")]
|
||||
[ViewVariables] [DataField("secretPartName", readOnly: true)]
|
||||
public string SecretPartName
|
||||
{
|
||||
get => _secretPartName;
|
||||
|
||||
@@ -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<ContentLocalizationManager>().Initialize();
|
||||
IoCManager.Resolve<MarkingManager>().Initialize();
|
||||
|
||||
var configMan = IoCManager.Resolve<IConfigurationManager>();
|
||||
|
||||
@@ -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<MarkingManager, MarkingManager>();
|
||||
IoCManager.Register<ContentLocalizationManager, ContentLocalizationManager>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ILocalizationManager>();
|
||||
var res = IoCManager.Resolve<IResourceManager>();
|
||||
|
||||
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}"),
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user