1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 10:02:54 +08:00

Replace switch expression with LocalisableDescription attribute for variant display

Use existing localisation strings from BeatmapsStrings instead of CommonStrings for consistent localisation handling
This commit is contained in:
Nicholas Chin 2024-12-12 22:39:21 +08:00
parent 26f15def70
commit a22f3416d6
2 changed files with 6 additions and 18 deletions

View File

@ -179,16 +179,6 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString CopyLink => new TranslatableString(getKey(@"copy_link"), @"Copy link");
/// <summary>
/// "4K"
/// </summary>
public static LocalisableString FourKey => new TranslatableString(getKey(@"four_key"), @"4K");
/// <summary>
/// "7K"
/// </summary>
public static LocalisableString SevenKey => new TranslatableString(getKey(@"seven_key"), @"7K");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
}

View File

@ -8,9 +8,10 @@ using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Framework.Extensions;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Scoring;
using osu.Game.Utils;
@ -128,8 +129,10 @@ namespace osu.Game.Users
public enum GameVariant
{
[EnumMember(Value = "4k")]
[LocalisableDescription(typeof(BeatmapsStrings), nameof(BeatmapsStrings.VariantMania4k))]
FourKey,
[EnumMember(Value = "7k")]
[LocalisableDescription(typeof(BeatmapsStrings), nameof(BeatmapsStrings.VariantMania7k))]
SevenKey
}
@ -151,12 +154,7 @@ namespace osu.Game.Users
[JsonConverter(typeof(StringEnumConverter))]
public GameVariant? VariantType;
public LocalisableString VariantDisplay => VariantType switch
{
GameVariant.FourKey => CommonStrings.FourKey,
GameVariant.SevenKey => CommonStrings.SevenKey,
_ => string.Empty
};
public LocalisableString VariantDisplay => VariantType?.GetLocalisableDescription() ?? string.Empty;
}
}
}