mirror of
https://github.com/ppy/osu.git
synced 2026-05-20 21:40:44 +08:00
Add localisation support
This commit is contained in:
@@ -64,6 +64,26 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString KeyBindingPanelDescription => new TranslatableString(getKey(@"key_binding_panel_description"), @"Customise your keys!");
|
||||
|
||||
/// <summary>
|
||||
/// "The binding you've selected conflicts with another existing binding."
|
||||
/// </summary>
|
||||
public static LocalisableString KeyBindingConflictDetected => new TranslatableString(getKey(@"key_binding_conflict_detected"), @"The binding you've selected conflicts with another existing binding.");
|
||||
|
||||
/// <summary>
|
||||
/// "Keep existing"
|
||||
/// </summary>
|
||||
public static LocalisableString KeepExisting => new TranslatableString(getKey(@"keep_existing"), @"Keep existing");
|
||||
|
||||
/// <summary>
|
||||
/// "Apply new"
|
||||
/// </summary>
|
||||
public static LocalisableString ApplyNew => new TranslatableString(getKey(@"apply_new"), @"Apply new");
|
||||
|
||||
/// <summary>
|
||||
/// "(none)"
|
||||
/// </summary>
|
||||
public static LocalisableString EmptyBinding => new TranslatableString(getKey(@"none"), @"(none)");
|
||||
|
||||
private static string getKey(string key) => $"{prefix}:{key}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@@ -18,6 +19,7 @@ using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
@@ -52,7 +54,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Text = "The binding you've selected conflicts with another existing binding.",
|
||||
Text = InputSettingsStrings.KeyBindingConflictDetected,
|
||||
Margin = new MarginPadding { Bottom = 10 }
|
||||
},
|
||||
existingPreview = new ConflictingKeyBindingPreview(
|
||||
@@ -72,7 +74,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
{
|
||||
keepExistingButton = new HoverableRoundedButton
|
||||
{
|
||||
Text = "Keep existing",
|
||||
Text = InputSettingsStrings.KeepExisting,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.48f,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
@@ -81,7 +83,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
},
|
||||
applyNewButton = new HoverableRoundedButton
|
||||
{
|
||||
Text = "Apply new",
|
||||
Text = InputSettingsStrings.ApplyNew,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.48f,
|
||||
Anchor = Anchor.CentreRight,
|
||||
@@ -243,30 +245,30 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
string newBinding;
|
||||
LocalisableString keyCombinationText;
|
||||
|
||||
switch (IsChosen.Value)
|
||||
{
|
||||
case true:
|
||||
newBinding = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||
newBindingText.Colour = colours.Green1;
|
||||
break;
|
||||
|
||||
case false:
|
||||
newBinding = keyCombinationProvider.GetReadableString(combinationWhenNotChosen);
|
||||
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenNotChosen);
|
||||
newBindingText.Colour = colours.Red1;
|
||||
break;
|
||||
|
||||
case null:
|
||||
newBinding = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||
keyCombinationText = keyCombinationProvider.GetReadableString(combinationWhenChosen);
|
||||
newBindingText.Colour = Colour4.White;
|
||||
break;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(newBinding))
|
||||
newBinding = "(none)";
|
||||
if (LocalisableString.IsNullOrEmpty(keyCombinationText))
|
||||
keyCombinationText = InputSettingsStrings.EmptyBinding;
|
||||
|
||||
newBindingText.Text = newBinding;
|
||||
newBindingText.Text = keyCombinationText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user