1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 15:04:26 +08:00

Add HumanisedLocalisableDate for l10n

This commit is contained in:
CloneWith
2025-09-10 07:48:09 +08:00
Unverified
parent ae0f9619b9
commit b3abd09517
+22 -1
View File
@@ -72,12 +72,33 @@ namespace osu.Game.Graphics
Scheduler.AddDelayed(updateTimeWithReschedule, timeUntilNextUpdate);
}
protected virtual LocalisableString Format() => HumanizerUtils.Humanize(Date);
protected virtual LocalisableString Format() => new LocalisableString(new HumanisedLocalisableDate(Date));
private void updateTime() => Text = Format();
public ITooltip<DateTimeOffset> GetCustomTooltip() => new DateTooltip();
public DateTimeOffset TooltipContent => Date;
private class HumanisedLocalisableDate : IEquatable<HumanisedLocalisableDate>, ILocalisableStringData
{
public readonly DateTimeOffset Date;
public HumanisedLocalisableDate(DateTimeOffset date)
{
Date = date;
}
public bool Equals(HumanisedLocalisableDate? other)
=> other?.Date != null && Date.Equals(other.Date);
public bool Equals(ILocalisableStringData? other)
=> other is HumanisedLocalisableDate otherDate && Equals(otherDate);
public string GetLocalised(LocalisationParameters parameters) => HumanizerUtils.Humanize(Date);
// Override for default string interpolations
public override string ToString() => HumanizerUtils.Humanize(Date);
}
}
}