1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-20 05:19:55 +08:00

Merge pull request #36114 from diquoks/localisation/play-v2

Localise various strings on `Play` screen (again)
This commit is contained in:
Bartłomiej Dach
2025-12-29 11:57:33 +01:00
committed by GitHub
Unverified
6 changed files with 77 additions and 11 deletions
@@ -39,6 +39,11 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString HitObjectsAppearEarlier => new TranslatableString(getKey(@"hit_objects_appear_earlier"), @"(hit objects appear earlier)");
/// <summary>
/// "Beatmap offset was adjusted to {0} ms."
/// </summary>
public static LocalisableString BeatmapOffsetWasAdjustedTo(string offset) => new TranslatableString(getKey(@"beatmap_offset_was_adjusted_to"), @"Beatmap offset was adjusted to {0} ms.", offset);
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
@@ -0,0 +1,39 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class RankingStatisticsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.RankingStatisticsStrings";
/// <summary>
/// "Average Hit Error"
/// </summary>
public static LocalisableString AverageHitErrorTitle => new TranslatableString(getKey(@"average_hit_error_title"), @"Average Hit Error");
/// <summary>
/// "Unstable Rate"
/// </summary>
public static LocalisableString UnstableRateTitle => new TranslatableString(getKey(@"unstable_rate_title"), @"Unstable Rate");
/// <summary>
/// "{0:N2} ms early"
/// </summary>
public static LocalisableString Early(double offset) => new TranslatableString(getKey(@"early"), @"{0:N2} ms early", offset);
/// <summary>
/// "{0:N2} ms late"
/// </summary>
public static LocalisableString Late(double offset) => new TranslatableString(getKey(@"late"), @"{0:N2} ms late", offset);
/// <summary>
/// "(not available)"
/// </summary>
public static LocalisableString NotAvailable => new TranslatableString(getKey(@"not_available"), @"(not available)");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
@@ -330,7 +330,7 @@ namespace osu.Game.Screens.Play.PlayerSettings
if (offsetChanged)
{
offsetText.AddText($"Beatmap offset was adjusted to {Current.Value.ToStandardFormattedString(1)} ms.", t => t.Font = OsuFont.Style.Caption1);
offsetText.AddText(BeatmapOffsetControlStrings.BeatmapOffsetWasAdjustedTo(Current.Value.ToStandardFormattedString(1)), t => t.Font = OsuFont.Style.Caption1);
offsetText.NewParagraph();
}
}
@@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
using osu.Framework.Localisation;
using osu.Game.Rulesets.Scoring;
using osu.Game.Localisation;
namespace osu.Game.Screens.Ranking.Statistics
{
@@ -17,11 +19,19 @@ namespace osu.Game.Screens.Ranking.Statistics
/// </summary>
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the unstable rate based on.</param>
public AverageHitError(IEnumerable<HitEvent> hitEvents)
: base("Average Hit Error")
: base(RankingStatisticsStrings.AverageHitErrorTitle)
{
Value = hitEvents.CalculateAverageHitError();
}
protected override string DisplayValue(double? value) => value == null ? "(not available)" : $"{Math.Abs(value.Value):N2} ms {(value.Value < 0 ? "early" : "late")}";
protected override LocalisableString DisplayValue(double? value)
{
return value == null ? RankingStatisticsStrings.NotAvailable : getEarlyLateText(value.Value);
LocalisableString getEarlyLateText(double offset) =>
offset < 0
? RankingStatisticsStrings.Early(Math.Abs(offset))
: RankingStatisticsStrings.Late(Math.Abs(offset));
}
}
}
@@ -1,8 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@@ -17,7 +20,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// <summary>
/// The text to display as the statistic's value.
/// </summary>
protected string Value
protected LocalisableString Value
{
set => valueText.Text = value;
}
@@ -41,9 +44,9 @@ namespace osu.Game.Screens.Ranking.Statistics
/// Creates a new simple statistic item.
/// </summary>
/// <param name="name">The name of the statistic.</param>
protected SimpleStatisticItem(string name)
protected SimpleStatisticItem(LocalisableString name)
{
Name = name;
Name = name.ToString();
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@@ -52,7 +55,7 @@ namespace osu.Game.Screens.Ranking.Statistics
{
nameText = new OsuSpriteText
{
Text = Name,
Text = name,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: StatisticItem.FONT_SIZE)
@@ -91,9 +94,15 @@ namespace osu.Game.Screens.Ranking.Statistics
/// Used to convert <see cref="Value"/> to a text representation.
/// Defaults to using <see cref="object.ToString"/>.
/// </summary>
protected virtual string DisplayValue(TValue value) => value!.ToString() ?? string.Empty;
protected virtual LocalisableString DisplayValue(TValue value)
{
if (value is IFormattable formattable)
return formattable.ToLocalisableString();
public SimpleStatisticItem(string name)
return value!.ToString() ?? string.Empty;
}
public SimpleStatisticItem(LocalisableString name)
: base(name)
{
}
@@ -2,6 +2,9 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Ranking.Statistics
@@ -16,11 +19,11 @@ namespace osu.Game.Screens.Ranking.Statistics
/// </summary>
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the unstable rate based on.</param>
public UnstableRate(IReadOnlyList<HitEvent> hitEvents)
: base("Unstable Rate")
: base(RankingStatisticsStrings.UnstableRateTitle)
{
Value = hitEvents.CalculateUnstableRate()?.Result;
}
protected override string DisplayValue(double? value) => value?.ToString(@"N2") ?? "(not available)";
protected override LocalisableString DisplayValue(double? value) => value?.ToLocalisableString(@"N2") ?? RankingStatisticsStrings.NotAvailable;
}
}