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:
Ed
2024-10-29 11:16:56 +03:00
388 changed files with 34535 additions and 18822 deletions

View File

@@ -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));
}
}
}