diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 9aa6372c66..b763d39c3b 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -7,6 +7,7 @@ using osu.Framework.Configuration; using osu.Framework.Configuration.Tracking; using osu.Framework.Extensions; using osu.Framework.Extensions.LocalisationExtensions; +using osu.Framework.Localisation; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Input; @@ -201,7 +202,7 @@ namespace osu.Game.Configuration public Func LookupSkinName { private get; set; } - public Func LookupKeyBindings { get; set; } + public Func LookupKeyBindings { get; set; } } // IMPORTANT: These are used in user configuration files. diff --git a/osu.Game/Localisation/ToastStrings.cs b/osu.Game/Localisation/ToastStrings.cs new file mode 100644 index 0000000000..52e75425bf --- /dev/null +++ b/osu.Game/Localisation/ToastStrings.cs @@ -0,0 +1,39 @@ +// Copyright (c) ppy Pty Ltd . 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 ToastStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.Toast"; + + /// + /// "no key bound" + /// + public static LocalisableString NoKeyBound => new TranslatableString(getKey(@"no_key_bound"), @"no key bound"); + + /// + /// "Music Playback" + /// + public static LocalisableString MusicPlayback => new TranslatableString(getKey(@"music_playback"), @"Music Playback"); + + /// + /// "Pause track" + /// + public static LocalisableString PauseTrack => new TranslatableString(getKey(@"pause_track"), @"Pause track"); + + /// + /// "Play track" + /// + public static LocalisableString PlayTrack => new TranslatableString(getKey(@"play_track"), @"Play track"); + + /// + /// "Restart track" + /// + public static LocalisableString RestartTrack => new TranslatableString(getKey(@"restart_track"), @"Restart track"); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 8a018f17d9..4bf122ace1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -638,7 +638,7 @@ namespace osu.Game var combinations = KeyBindingStore.GetReadableKeyCombinationsFor(l); if (combinations.Count == 0) - return "none"; + return ToastStrings.NoKeyBound; return string.Join(" or ", combinations); }; diff --git a/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs b/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs index 6fb7fb6591..18ec69e106 100644 --- a/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs +++ b/osu.Game/Overlays/Music/MusicKeyBindingHandler.cs @@ -3,6 +3,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; @@ -41,7 +42,7 @@ namespace osu.Game.Overlays.Music bool wasPlaying = musicController.IsPlaying; if (musicController.TogglePause()) - onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? "Pause track" : "Play track", e.Action)); + onScreenDisplay?.Display(new MusicActionToast(wasPlaying ? ToastStrings.PauseTrack : ToastStrings.PlayTrack, e.Action)); return true; case GlobalAction.MusicNext: @@ -55,7 +56,7 @@ namespace osu.Game.Overlays.Music switch (res) { case PreviousTrackResult.Restart: - onScreenDisplay?.Display(new MusicActionToast("Restart track", e.Action)); + onScreenDisplay?.Display(new MusicActionToast(ToastStrings.RestartTrack, e.Action)); break; case PreviousTrackResult.Previous: @@ -79,7 +80,7 @@ namespace osu.Game.Overlays.Music private readonly GlobalAction action; public MusicActionToast(LocalisableString value, GlobalAction action) - : base("Music Playback", value, string.Empty) + : base(ToastStrings.MusicPlayback, value, string.Empty) { this.action = action; } @@ -87,7 +88,7 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - ShortcutText.Text = config.LookupKeyBindings(action).ToUpperInvariant(); + ShortcutText.Text = config.LookupKeyBindings(action).ToUpper(); } } } diff --git a/osu.Game/Overlays/OSD/Toast.cs b/osu.Game/Overlays/OSD/Toast.cs index 1289943123..12e30d8de2 100644 --- a/osu.Game/Overlays/OSD/Toast.cs +++ b/osu.Game/Overlays/OSD/Toast.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osuTK; using osuTK.Graphics; +using osu.Game.Localisation; namespace osu.Game.Overlays.OSD { @@ -81,7 +82,7 @@ namespace osu.Game.Overlays.OSD Alpha = 0.3f, Margin = new MarginPadding { Bottom = 15, Horizontal = 10 }, Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold), - Text = string.IsNullOrEmpty(shortcut.ToString()) ? (LocalisableString)"NO KEY BOUND" : shortcut.ToUpper() + Text = string.IsNullOrEmpty(shortcut.ToString()) ? ToastStrings.NoKeyBound.ToUpper() : shortcut.ToUpper() }, }; }