Merge remote-tracking branch 'upstream/stable' into ed-29-10-2024-upstream
# Conflicts: # Content.Server/Chat/Managers/ChatSanitizationManager.cs # Content.Server/Temperature/Systems/TemperatureSystem.cs # Content.Shared/Localizations/ContentLocalizationManager.cs
This commit is contained in:
@@ -41,6 +41,8 @@ namespace Content.Shared.Localizations
|
||||
_loc.AddFunction(culture, "LOC", FormatLoc);
|
||||
_loc.AddFunction(culture, "NATURALFIXED", FormatNaturalFixed);
|
||||
_loc.AddFunction(culture, "NATURALPERCENT", FormatNaturalPercent);
|
||||
_loc.AddFunction(culture, "PLAYTIME", FormatPlaytime);
|
||||
|
||||
_loc.AddFunction(culture, "MANY", FormatMany); // TODO: Temporary fix for MANY() fluent errors. Remove after resolve errors.
|
||||
|
||||
/*
|
||||
@@ -151,6 +153,16 @@ namespace Content.Shared.Localizations
|
||||
return Loc.GetString($"zzzz-fmt-direction-{dir.ToString()}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats playtime as hours and minutes.
|
||||
/// </summary>
|
||||
public static string FormatPlaytime(TimeSpan time)
|
||||
{
|
||||
var hours = (int)time.TotalHours;
|
||||
var minutes = time.Minutes;
|
||||
return Loc.GetString($"zzzz-fmt-playtime", ("hours", hours), ("minutes", minutes));
|
||||
}
|
||||
|
||||
private static ILocValue FormatLoc(LocArgs args)
|
||||
{
|
||||
var id = ((LocValueString) args.Args[0]).Value;
|
||||
@@ -239,5 +251,15 @@ namespace Content.Shared.Localizations
|
||||
|
||||
return new LocValueString(res);
|
||||
}
|
||||
|
||||
private static ILocValue FormatPlaytime(LocArgs args)
|
||||
{
|
||||
var time = TimeSpan.Zero;
|
||||
if (args.Args is { Count: > 0 } && args.Args[0].Value is TimeSpan timeArg)
|
||||
{
|
||||
time = timeArg;
|
||||
}
|
||||
return new LocValueString(FormatPlaytime(time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user