mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-10 04:39:11 +00:00
Start localising
This commit is contained in:
parent
4a92d0b482
commit
c567f40531
2 changed files with 86 additions and 4 deletions
|
@ -266,6 +266,33 @@
|
|||
"ControllerSettingsMotionGyroDeadzone": "Gyro Deadzone:",
|
||||
"ControllerSettingsSave": "Save",
|
||||
"ControllerSettingsClose": "Close",
|
||||
"KeyUnknown": "Unknown",
|
||||
"KeyShiftLeft": "Shift Left",
|
||||
"KeyShiftRight": "Shift Right",
|
||||
"KeyControlLeft": "Control Left",
|
||||
"KeyControlRight": "Control Right",
|
||||
"KeyAltLeft": "Alt Left",
|
||||
"KeyAltRight": "Alt Right",
|
||||
"KeyOptLeft": "⌥ Left",
|
||||
"KeyOptRight": "⌥ Right",
|
||||
"KeyWinLeft": "Windows Left",
|
||||
"KeyWinRight": "Windows Right",
|
||||
"KeyCmdLeft": "⌘ Left",
|
||||
"KeyCmdRight": "⌘ Right",
|
||||
"KeyMenu": "Menu",
|
||||
"KeyUp": "Up",
|
||||
"KeyDown": "Down",
|
||||
"KeyLeft": "Left",
|
||||
"KeyRight": "Right",
|
||||
"KeyEnter": "Enter",
|
||||
"KeyEscape": "Escape",
|
||||
"KeySpace": "Space",
|
||||
"KeyTab": "Tab",
|
||||
"KeyBackSpace": "Backspace",
|
||||
"KeyInsert": "Insert",
|
||||
"KeyDelete": "Delete",
|
||||
"KeyPageUp": "Page Up",
|
||||
"KeyPageDown": "Page Down",
|
||||
"UserProfilesSelectedUserProfile": "Selected User Profile:",
|
||||
"UserProfilesSaveProfileName": "Save Profile Name",
|
||||
"UserProfilesChangeProfileImage": "Change Profile Image",
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using DynamicData.Kernel;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Common.Configuration.Hid;
|
||||
using Ryujinx.Common.Configuration.Hid.Controller;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Helpers
|
||||
|
@ -9,15 +12,59 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
internal class KeyValueConverter : IValueConverter
|
||||
{
|
||||
public static KeyValueConverter Instance = new();
|
||||
internal static readonly Dictionary<Key, LocaleKeys> KeysMap = new()
|
||||
{
|
||||
{ Key.Unknown, LocaleKeys.KeyUnknown },
|
||||
{ Key.ShiftLeft, LocaleKeys.KeyShiftLeft },
|
||||
{ Key.ShiftRight, LocaleKeys.KeyShiftRight },
|
||||
{ Key.ControlLeft, LocaleKeys.KeyControlLeft },
|
||||
{ Key.ControlRight, LocaleKeys.KeyControlRight },
|
||||
{ Key.AltLeft, OperatingSystem.IsMacOS() ? LocaleKeys.KeyOptLeft : LocaleKeys.KeyAltLeft },
|
||||
{ Key.AltRight, OperatingSystem.IsMacOS() ? LocaleKeys.KeyOptRight : LocaleKeys.KeyAltRight },
|
||||
{ Key.WinLeft, OperatingSystem.IsMacOS() ? LocaleKeys.KeyCmdLeft : LocaleKeys.KeyWinLeft },
|
||||
{ Key.WinRight, OperatingSystem.IsMacOS() ? LocaleKeys.KeyCmdRight : LocaleKeys.KeyWinRight },
|
||||
{ Key.Up, LocaleKeys.KeyUp },
|
||||
{ Key.Down, LocaleKeys.KeyDown },
|
||||
{ Key.Left, LocaleKeys.KeyLeft },
|
||||
{ Key.Right, LocaleKeys.KeyRight },
|
||||
{ Key.Enter, LocaleKeys.KeyEnter },
|
||||
{ Key.Escape, LocaleKeys.KeyEscape },
|
||||
{ Key.Space, LocaleKeys.KeySpace },
|
||||
{ Key.Tab, LocaleKeys.KeyTab },
|
||||
{ Key.BackSpace, LocaleKeys.KeyBackSpace },
|
||||
{ Key.Insert, LocaleKeys.KeyInsert },
|
||||
{ Key.Delete, LocaleKeys.KeyDelete },
|
||||
{ Key.PageUp, LocaleKeys.KeyPageUp },
|
||||
{ Key.PageDown, LocaleKeys.KeyPageDown },
|
||||
};
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
string keyString = "";
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
return null;
|
||||
if (value is Key key)
|
||||
{
|
||||
if (KeysMap.TryGetValue(key, out LocaleKeys localeKey))
|
||||
{
|
||||
keyString = LocaleManager.Instance[localeKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
keyString = key.ToString();
|
||||
}
|
||||
}
|
||||
else if (value is GamepadInputId gamepadInputId)
|
||||
{
|
||||
keyString = value.ToString();
|
||||
}
|
||||
else if (value is StickInputId stickInputId)
|
||||
{ keyString = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return value.ToString();
|
||||
return keyString;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
@ -28,7 +75,15 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
{
|
||||
if (targetType == typeof(Key))
|
||||
{
|
||||
key = Enum.Parse<Key>(value.ToString());
|
||||
var optionalKey = KeysMap.FirstOrOptional(x => LocaleManager.Instance[x.Value] == value.ToString());
|
||||
if (optionalKey.HasValue)
|
||||
{
|
||||
key = optionalKey.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = Enum.Parse<Key>(value.ToString());
|
||||
}
|
||||
}
|
||||
else if (targetType == typeof(GamepadInputId))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue