Merge pull request #14763 from kj415j45/localisation-settings-GlobalAction

Add localisation for Settings-KeyBindings-GlobalActions
This commit is contained in:
Dean Herbert 2021-09-16 21:08:00 +09:00 committed by GitHub
commit df786afb24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 307 additions and 52 deletions

View File

@ -234,7 +234,7 @@ namespace osu.Game.Tests.Visual.Settings
{ {
AddAssert($"Check {name} is bound to {keyName}", () => AddAssert($"Check {name} is bound to {keyName}", () =>
{ {
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text == name)); var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
var firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First(); var firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();
return firstButton.Text.Text == keyName; return firstButton.Text.Text == keyName;
@ -247,7 +247,7 @@ namespace osu.Game.Tests.Visual.Settings
AddStep($"Scroll to {name}", () => AddStep($"Scroll to {name}", () =>
{ {
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text == name)); var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First(); firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();
panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(firstButton); panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(firstButton);

View File

@ -2,11 +2,12 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Localisation;
using osu.Game.Localisation;
namespace osu.Game.Input.Bindings namespace osu.Game.Input.Bindings
{ {
@ -137,152 +138,152 @@ namespace osu.Game.Input.Bindings
public enum GlobalAction public enum GlobalAction
{ {
[Description("Toggle chat overlay")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleChat))]
ToggleChat, ToggleChat,
[Description("Toggle social overlay")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleSocial))]
ToggleSocial, ToggleSocial,
[Description("Reset input settings")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ResetInputSettings))]
ResetInputSettings, ResetInputSettings,
[Description("Toggle toolbar")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleToolbar))]
ToggleToolbar, ToggleToolbar,
[Description("Toggle settings")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleSettings))]
ToggleSettings, ToggleSettings,
[Description("Toggle beatmap listing")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleBeatmapListing))]
ToggleBeatmapListing, ToggleBeatmapListing,
[Description("Increase volume")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseVolume))]
IncreaseVolume, IncreaseVolume,
[Description("Decrease volume")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DecreaseVolume))]
DecreaseVolume, DecreaseVolume,
[Description("Toggle mute")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleMute))]
ToggleMute, ToggleMute,
// In-Game Keybindings // In-Game Keybindings
[Description("Skip cutscene")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SkipCutscene))]
SkipCutscene, SkipCutscene,
[Description("Quick retry (hold)")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.QuickRetry))]
QuickRetry, QuickRetry,
[Description("Take screenshot")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.TakeScreenshot))]
TakeScreenshot, TakeScreenshot,
[Description("Toggle gameplay mouse buttons")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleGameplayMouseButtons))]
ToggleGameplayMouseButtons, ToggleGameplayMouseButtons,
[Description("Back")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.Back))]
Back, Back,
[Description("Increase scroll speed")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.IncreaseScrollSpeed))]
IncreaseScrollSpeed, IncreaseScrollSpeed,
[Description("Decrease scroll speed")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.DecreaseScrollSpeed))]
DecreaseScrollSpeed, DecreaseScrollSpeed,
[Description("Select")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.Select))]
Select, Select,
[Description("Quick exit (hold)")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.QuickExit))]
QuickExit, QuickExit,
// Game-wide beatmap music controller keybindings // Game-wide beatmap music controller keybindings
[Description("Next track")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MusicNext))]
MusicNext, MusicNext,
[Description("Previous track")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MusicPrev))]
MusicPrev, MusicPrev,
[Description("Play / pause")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MusicPlay))]
MusicPlay, MusicPlay,
[Description("Toggle now playing overlay")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleNowPlaying))]
ToggleNowPlaying, ToggleNowPlaying,
[Description("Previous selection")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectPrevious))]
SelectPrevious, SelectPrevious,
[Description("Next selection")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectNext))]
SelectNext, SelectNext,
[Description("Home")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.Home))]
Home, Home,
[Description("Toggle notifications")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleNotifications))]
ToggleNotifications, ToggleNotifications,
[Description("Pause gameplay")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.PauseGameplay))]
PauseGameplay, PauseGameplay,
// Editor // Editor
[Description("Setup mode")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorSetupMode))]
EditorSetupMode, EditorSetupMode,
[Description("Compose mode")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorComposeMode))]
EditorComposeMode, EditorComposeMode,
[Description("Design mode")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorDesignMode))]
EditorDesignMode, EditorDesignMode,
[Description("Timing mode")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTimingMode))]
EditorTimingMode, EditorTimingMode,
[Description("Hold for HUD")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.HoldForHUD))]
HoldForHUD, HoldForHUD,
[Description("Random skin")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.RandomSkin))]
RandomSkin, RandomSkin,
[Description("Pause / resume replay")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.TogglePauseReplay))]
TogglePauseReplay, TogglePauseReplay,
[Description("Toggle in-game interface")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleInGameInterface))]
ToggleInGameInterface, ToggleInGameInterface,
// Song select keybindings // Song select keybindings
[Description("Toggle Mod Select")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleModSelection))]
ToggleModSelection, ToggleModSelection,
[Description("Random")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectNextRandom))]
SelectNextRandom, SelectNextRandom,
[Description("Rewind")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SelectPreviousRandom))]
SelectPreviousRandom, SelectPreviousRandom,
[Description("Beatmap Options")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleBeatmapOptions))]
ToggleBeatmapOptions, ToggleBeatmapOptions,
[Description("Verify mode")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorVerifyMode))]
EditorVerifyMode, EditorVerifyMode,
[Description("Nudge selection left")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorNudgeLeft))]
EditorNudgeLeft, EditorNudgeLeft,
[Description("Nudge selection right")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorNudgeRight))]
EditorNudgeRight, EditorNudgeRight,
[Description("Toggle skin editor")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleSkinEditor))]
ToggleSkinEditor, ToggleSkinEditor,
[Description("Previous volume meter")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.PreviousVolumeMeter))]
PreviousVolumeMeter, PreviousVolumeMeter,
[Description("Next volume meter")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.NextVolumeMeter))]
NextVolumeMeter, NextVolumeMeter,
[Description("Seek replay forward")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SeekReplayForward))]
SeekReplayForward, SeekReplayForward,
[Description("Seek replay backward")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.SeekReplayBackward))]
SeekReplayBackward, SeekReplayBackward,
[Description("Toggle chat focus")] [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.ToggleChatFocus))]
ToggleChatFocus ToggleChatFocus
} }
} }

View File

@ -0,0 +1,254 @@
// 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 GlobalActionKeyBindingStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.GlobalActionKeyBinding";
/// <summary>
/// "Toggle chat overlay"
/// </summary>
public static LocalisableString ToggleChat => new TranslatableString(getKey(@"toggle_chat"), @"Toggle chat overlay");
/// <summary>
/// "Toggle social overlay"
/// </summary>
public static LocalisableString ToggleSocial => new TranslatableString(getKey(@"toggle_social"), @"Toggle social overlay");
/// <summary>
/// "Reset input settings"
/// </summary>
public static LocalisableString ResetInputSettings => new TranslatableString(getKey(@"reset_input_settings"), @"Reset input settings");
/// <summary>
/// "Toggle toolbar"
/// </summary>
public static LocalisableString ToggleToolbar => new TranslatableString(getKey(@"toggle_toolbar"), @"Toggle toolbar");
/// <summary>
/// "Toggle settings"
/// </summary>
public static LocalisableString ToggleSettings => new TranslatableString(getKey(@"toggle_settings"), @"Toggle settings");
/// <summary>
/// "Toggle beatmap listing"
/// </summary>
public static LocalisableString ToggleBeatmapListing => new TranslatableString(getKey(@"toggle_beatmap_listing"), @"Toggle beatmap listing");
/// <summary>
/// "Increase volume"
/// </summary>
public static LocalisableString IncreaseVolume => new TranslatableString(getKey(@"increase_volume"), @"Increase volume");
/// <summary>
/// "Decrease volume"
/// </summary>
public static LocalisableString DecreaseVolume => new TranslatableString(getKey(@"decrease_volume"), @"Decrease volume");
/// <summary>
/// "Toggle mute"
/// </summary>
public static LocalisableString ToggleMute => new TranslatableString(getKey(@"toggle_mute"), @"Toggle mute");
/// <summary>
/// "Skip cutscene"
/// </summary>
public static LocalisableString SkipCutscene => new TranslatableString(getKey(@"skip_cutscene"), @"Skip cutscene");
/// <summary>
/// "Quick retry (hold)"
/// </summary>
public static LocalisableString QuickRetry => new TranslatableString(getKey(@"quick_retry"), @"Quick retry (hold)");
/// <summary>
/// "Take screenshot"
/// </summary>
public static LocalisableString TakeScreenshot => new TranslatableString(getKey(@"take_screenshot"), @"Take screenshot");
/// <summary>
/// "Toggle gameplay mouse buttons"
/// </summary>
public static LocalisableString ToggleGameplayMouseButtons => new TranslatableString(getKey(@"toggle_gameplay_mouse_buttons"), @"Toggle gameplay mouse buttons");
/// <summary>
/// "Back"
/// </summary>
public static LocalisableString Back => new TranslatableString(getKey(@"back"), @"Back");
/// <summary>
/// "Increase scroll speed"
/// </summary>
public static LocalisableString IncreaseScrollSpeed => new TranslatableString(getKey(@"increase_scroll_speed"), @"Increase scroll speed");
/// <summary>
/// "Decrease scroll speed"
/// </summary>
public static LocalisableString DecreaseScrollSpeed => new TranslatableString(getKey(@"decrease_scroll_speed"), @"Decrease scroll speed");
/// <summary>
/// "Select"
/// </summary>
public static LocalisableString Select => new TranslatableString(getKey(@"select"), @"Select");
/// <summary>
/// "Quick exit (hold)"
/// </summary>
public static LocalisableString QuickExit => new TranslatableString(getKey(@"quick_exit"), @"Quick exit (hold)");
/// <summary>
/// "Next track"
/// </summary>
public static LocalisableString MusicNext => new TranslatableString(getKey(@"music_next"), @"Next track");
/// <summary>
/// "Previous track"
/// </summary>
public static LocalisableString MusicPrev => new TranslatableString(getKey(@"music_prev"), @"Previous track");
/// <summary>
/// "Play / pause"
/// </summary>
public static LocalisableString MusicPlay => new TranslatableString(getKey(@"music_play"), @"Play / pause");
/// <summary>
/// "Toggle now playing overlay"
/// </summary>
public static LocalisableString ToggleNowPlaying => new TranslatableString(getKey(@"toggle_now_playing"), @"Toggle now playing overlay");
/// <summary>
/// "Previous selection"
/// </summary>
public static LocalisableString SelectPrevious => new TranslatableString(getKey(@"select_previous"), @"Previous selection");
/// <summary>
/// "Next selection"
/// </summary>
public static LocalisableString SelectNext => new TranslatableString(getKey(@"select_next"), @"Next selection");
/// <summary>
/// "Home"
/// </summary>
public static LocalisableString Home => new TranslatableString(getKey(@"home"), @"Home");
/// <summary>
/// "Toggle notifications"
/// </summary>
public static LocalisableString ToggleNotifications => new TranslatableString(getKey(@"toggle_notifications"), @"Toggle notifications");
/// <summary>
/// "Pause gameplay"
/// </summary>
public static LocalisableString PauseGameplay => new TranslatableString(getKey(@"pause_gameplay"), @"Pause gameplay");
/// <summary>
/// "Setup mode"
/// </summary>
public static LocalisableString EditorSetupMode => new TranslatableString(getKey(@"editor_setup_mode"), @"Setup mode");
/// <summary>
/// "Compose mode"
/// </summary>
public static LocalisableString EditorComposeMode => new TranslatableString(getKey(@"editor_compose_mode"), @"Compose mode");
/// <summary>
/// "Design mode"
/// </summary>
public static LocalisableString EditorDesignMode => new TranslatableString(getKey(@"editor_design_mode"), @"Design mode");
/// <summary>
/// "Timing mode"
/// </summary>
public static LocalisableString EditorTimingMode => new TranslatableString(getKey(@"editor_timing_mode"), @"Timing mode");
/// <summary>
/// "Hold for HUD"
/// </summary>
public static LocalisableString HoldForHUD => new TranslatableString(getKey(@"hold_for_hud"), @"Hold for HUD");
/// <summary>
/// "Random skin"
/// </summary>
public static LocalisableString RandomSkin => new TranslatableString(getKey(@"random_skin"), @"Random skin");
/// <summary>
/// "Pause / resume replay"
/// </summary>
public static LocalisableString TogglePauseReplay => new TranslatableString(getKey(@"toggle_pause_replay"), @"Pause / resume replay");
/// <summary>
/// "Toggle in-game interface"
/// </summary>
public static LocalisableString ToggleInGameInterface => new TranslatableString(getKey(@"toggle_in_game_interface"), @"Toggle in-game interface");
/// <summary>
/// "Toggle Mod Select"
/// </summary>
public static LocalisableString ToggleModSelection => new TranslatableString(getKey(@"toggle_mod_selection"), @"Toggle Mod Select");
/// <summary>
/// "Random"
/// </summary>
public static LocalisableString SelectNextRandom => new TranslatableString(getKey(@"select_next_random"), @"Random");
/// <summary>
/// "Rewind"
/// </summary>
public static LocalisableString SelectPreviousRandom => new TranslatableString(getKey(@"select_previous_random"), @"Rewind");
/// <summary>
/// "Beatmap Options"
/// </summary>
public static LocalisableString ToggleBeatmapOptions => new TranslatableString(getKey(@"toggle_beatmap_options"), @"Beatmap Options");
/// <summary>
/// "Verify mode"
/// </summary>
public static LocalisableString EditorVerifyMode => new TranslatableString(getKey(@"editor_verify_mode"), @"Verify mode");
/// <summary>
/// "Nudge selection left"
/// </summary>
public static LocalisableString EditorNudgeLeft => new TranslatableString(getKey(@"editor_nudge_left"), @"Nudge selection left");
/// <summary>
/// "Nudge selection right"
/// </summary>
public static LocalisableString EditorNudgeRight => new TranslatableString(getKey(@"editor_nudge_right"), @"Nudge selection right");
/// <summary>
/// "Toggle skin editor"
/// </summary>
public static LocalisableString ToggleSkinEditor => new TranslatableString(getKey(@"toggle_skin_editor"), @"Toggle skin editor");
/// <summary>
/// "Previous volume meter"
/// </summary>
public static LocalisableString PreviousVolumeMeter => new TranslatableString(getKey(@"previous_volume_meter"), @"Previous volume meter");
/// <summary>
/// "Next volume meter"
/// </summary>
public static LocalisableString NextVolumeMeter => new TranslatableString(getKey(@"next_volume_meter"), @"Next volume meter");
/// <summary>
/// "Seek replay forward"
/// </summary>
public static LocalisableString SeekReplayForward => new TranslatableString(getKey(@"seek_replay_forward"), @"Seek replay forward");
/// <summary>
/// "Seek replay backward"
/// </summary>
public static LocalisableString SeekReplayBackward => new TranslatableString(getKey(@"seek_replay_backward"), @"Seek replay backward");
/// <summary>
/// "Toggle chat focus"
/// </summary>
public static LocalisableString ToggleChatFocus => new TranslatableString(getKey(@"toggle_chat_focus"), @"Toggle chat focus");
private static string getKey(string key) => $"{prefix}:{key}";
}
}

View File

@ -115,7 +115,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
}, },
text = new OsuSpriteText text = new OsuSpriteText
{ {
Text = action.GetDescription(), Text = action.GetLocalisableDescription(),
Margin = new MarginPadding(padding), Margin = new MarginPadding(padding),
}, },
buttons = new FillFlowContainer<KeyButton> buttons = new FillFlowContainer<KeyButton>