From 224b1dfb218f253c9abee06db442244cf69b1d18 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Mon, 7 Nov 2022 20:04:13 +0800 Subject: [PATCH] Translate BuiltinShortcut desc --- .../UserSettings/Settings.cs | 2 +- .../Converters/TranslationConverter.cs | 20 +++++++++++++++++++ Flow.Launcher/Languages/en.xaml | 1 + Flow.Launcher/SettingWindow.xaml | 13 ++++++------ .../ViewModel/SettingWindowViewModel.cs | 1 + 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 Flow.Launcher/Converters/TranslationConverter.cs diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 85a975275..7ead7459f 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -190,7 +190,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings [JsonIgnore] public ObservableCollection BuiltinShortcuts { get; set; } = new ObservableCollection() { - new BuiltinShortcutModel("{clipboard}", "Get text from clipboard.", Clipboard.GetText) // TODO: translation? + new BuiltinShortcutModel("{clipboard}", "shortcut_clipboard_description", Clipboard.GetText) }; public bool DontPromptUpdateMsg { get; set; } diff --git a/Flow.Launcher/Converters/TranslationConverter.cs b/Flow.Launcher/Converters/TranslationConverter.cs new file mode 100644 index 000000000..e1e8a58e3 --- /dev/null +++ b/Flow.Launcher/Converters/TranslationConverter.cs @@ -0,0 +1,20 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using Flow.Launcher.Core.Resource; + +namespace Flow.Launcher.Converters +{ + public class TranlationConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var key = value.ToString(); + if (String.IsNullOrEmpty(key)) + return key; + return InternationalizationManager.Instance.GetTranslation(key); + } + + public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException(); + } +} diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 54da5b74d..2e3922d06 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -148,6 +148,7 @@ Query Shortcut Expanded + Description Delete Edit Add diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 6d66184f5..3c0905aa7 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -41,6 +41,7 @@ + @@ -2531,14 +2532,14 @@ Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"> - + - + @@ -2586,21 +2587,21 @@ Background="{DynamicResource Color02B}" BorderBrush="DarkGray" BorderThickness="1" - ItemsSource="{Binding Settings.BuiltinShortcuts}" + ItemsSource="{Binding BuiltinShortcuts}" Style="{StaticResource {x:Static GridView.GridViewStyleKey}}"> - + - + - + diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 103150d04..63b9c29c9 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -224,6 +224,7 @@ namespace Flow.Launcher.ViewModel public IEnumerable MaxResultsRange => Enumerable.Range(2, 16); public ObservableCollection CustomShortcuts => Settings.CustomShortcuts; + public ObservableCollection BuiltinShortcuts => Settings.BuiltinShortcuts; public string TestProxy() {