Skip to content

Commit 1fea8ed

Browse files
committed
Add translation for default items & new profile item for explorer & browser window
1 parent 2dd4160 commit 1fea8ed

File tree

9 files changed

+49
-22
lines changed

9 files changed

+49
-22
lines changed

Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
using System.Text.Json.Serialization;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
13
using Flow.Launcher.Plugin;
2-
using System.Text.Json.Serialization;
34

45
namespace Flow.Launcher.Infrastructure.UserSettings
56
{
67
public class CustomBrowserViewModel : BaseModel
78
{
9+
// We should not initialize API in static constructor because it will create another API instance
10+
private static IPublicAPI api = null;
11+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
12+
813
public string Name { get; set; }
14+
[JsonIgnore]
15+
public string DisplayName => Name == "Default" ? API.GetTranslation("defaultBrowser_default") : Name;
916
public string Path { get; set; }
1017
public string PrivateArg { get; set; }
1118
public bool EnablePrivate { get; set; }
@@ -26,8 +33,10 @@ public CustomBrowserViewModel Copy()
2633
Editable = Editable
2734
};
2835
}
36+
37+
public void OnDisplayNameChanged()
38+
{
39+
OnPropertyChanged(nameof(DisplayName));
40+
}
2941
}
3042
}
31-
32-
33-

Flow.Launcher.Infrastructure/UserSettings/CustomExplorerViewModel.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
using Flow.Launcher.Plugin;
1+
using System.Text.Json.Serialization;
2+
using CommunityToolkit.Mvvm.DependencyInjection;
3+
using Flow.Launcher.Plugin;
24

35
namespace Flow.Launcher.ViewModel
46
{
57
public class CustomExplorerViewModel : BaseModel
68
{
9+
// We should not initialize API in static constructor because it will create another API instance
10+
private static IPublicAPI api = null;
11+
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
12+
713
public string Name { get; set; }
14+
[JsonIgnore]
15+
public string DisplayName => Name == "Explorer" ? API.GetTranslation("fileManagerExplorer") : Name;
816
public string Path { get; set; }
917
public string FileArgument { get; set; } = "\"%d\"";
1018
public string DirectoryArgument { get; set; } = "\"%d\"";
@@ -21,5 +29,10 @@ public CustomExplorerViewModel Copy()
2129
Editable = Editable
2230
};
2331
}
32+
33+
public void OnDisplayNameChanged()
34+
{
35+
OnPropertyChanged(nameof(DisplayName));
36+
}
2437
}
2538
}

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@
487487
<system:String x:Key="fileManager_file_arg">Arg For File</system:String>
488488
<system:String x:Key="fileManagerPathNotFound">The file manager '{0}' could not be located at '{1}'. Would you like to continue?</system:String>
489489
<system:String x:Key="fileManagerPathError">File Manager Path Error</system:String>
490+
<system:String x:Key="fileManagerExplorer">File Explorer</system:String>
490491

491492
<!-- DefaultBrowser Setting Dialog -->
492493
<system:String x:Key="defaultBrowserTitle">Default Web Browser</system:String>
@@ -497,6 +498,8 @@
497498
<system:String x:Key="defaultBrowser_newWindow">New Window</system:String>
498499
<system:String x:Key="defaultBrowser_newTab">New Tab</system:String>
499500
<system:String x:Key="defaultBrowser_parameter">Private Mode</system:String>
501+
<system:String x:Key="defaultBrowser_default">Default</system:String>
502+
<system:String x:Key="defaultBrowser_new_profile">New Profile</system:String>
500503

501504
<!-- Priority Setting Dialog -->
502505
<system:String x:Key="changePriorityWindow">Change Priority</system:String>

Flow.Launcher/SelectBrowserWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
SelectedIndex="{Binding SelectedCustomBrowserIndex}">
9393
<ComboBox.ItemTemplate>
9494
<DataTemplate>
95-
<TextBlock Text="{Binding Name}" />
95+
<TextBlock Text="{Binding DisplayName}" />
9696
</DataTemplate>
9797
</ComboBox.ItemTemplate>
9898
</ComboBox>

Flow.Launcher/SelectBrowserWindow.xaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private void btnDone_Click(object sender, RoutedEventArgs e)
3131

3232
private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
3333
{
34-
var selectedFilePath = _viewModel.SelectFile();
34+
var selectedFilePath = SelectFile();
3535

3636
if (!string.IsNullOrEmpty(selectedFilePath))
3737
{
@@ -41,5 +41,15 @@ private void btnBrowseFile_Click(object sender, RoutedEventArgs e)
4141
((Button)sender).Focus();
4242
}
4343
}
44+
45+
private static string SelectFile()
46+
{
47+
var dlg = new Microsoft.Win32.OpenFileDialog();
48+
var result = dlg.ShowDialog();
49+
if (result == true)
50+
return dlg.FileName;
51+
52+
return string.Empty;
53+
}
4454
}
4555
}

Flow.Launcher/SelectFileManagerWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
SelectedIndex="{Binding SelectedCustomExplorerIndex}">
103103
<ComboBox.ItemTemplate>
104104
<DataTemplate>
105-
<TextBlock Text="{Binding Name}" />
105+
<TextBlock Text="{Binding DisplayName}" />
106106
</DataTemplate>
107107
</ComboBox.ItemTemplate>
108108
</ComboBox>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Windows.Forms;
@@ -219,6 +219,8 @@ private void UpdateEnumDropdownLocalizations()
219219
DropdownDataGeneric<DialogJumpFileResultBehaviours>.UpdateLabels(DialogJumpFileResultBehaviours);
220220
// Since we are using Binding instead of DynamicResource, we need to manually trigger the update
221221
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
222+
Settings.CustomExplorer.OnDisplayNameChanged();
223+
Settings.CustomBrowser.OnDisplayNameChanged();
222224
}
223225

224226
public string Language

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
MaxWidth="250"
404404
Margin="10 0 0 0"
405405
Command="{Binding SelectFileManagerCommand}"
406-
Content="{Binding Settings.CustomExplorer.Name}" />
406+
Content="{Binding Settings.CustomExplorer.DisplayName}" />
407407
</cc:Card>
408408

409409
<cc:Card
@@ -415,7 +415,7 @@
415415
MaxWidth="250"
416416
Margin="10 0 0 0"
417417
Command="{Binding SelectBrowserCommand}"
418-
Content="{Binding Settings.CustomBrowser.Name}" />
418+
Content="{Binding Settings.CustomBrowser.DisplayName}" />
419419
</cc:Card>
420420

421421
<cc:Card Title="{DynamicResource pythonFilePath}" Margin="0 14 0 0">

Flow.Launcher/ViewModel/SelectBrowserViewModel.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,12 @@ public bool SaveSettings()
4040
return true;
4141
}
4242

43-
internal string SelectFile()
44-
{
45-
var dlg = new Microsoft.Win32.OpenFileDialog();
46-
var result = dlg.ShowDialog();
47-
if (result == true)
48-
return dlg.FileName;
49-
50-
return string.Empty;
51-
}
52-
5343
[RelayCommand]
5444
private void Add()
5545
{
5646
CustomBrowsers.Add(new()
5747
{
58-
Name = "New Profile"
48+
Name = App.API.GetTranslation("defaultBrowser_new_profile")
5949
});
6050
SelectedCustomBrowserIndex = CustomBrowsers.Count - 1;
6151
}

0 commit comments

Comments
 (0)