Slight localization func cleanup (#11380)
This commit is contained in:
@@ -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}"),
|
||||
Reference in New Issue
Block a user