Skip to content

Commit ca970bb

Browse files
committed
Localize startup messages about missing Python/NodeJS
1 parent 9b9ebfc commit ca970bb

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.IO;
88
using System.Linq;
99
using System.Windows.Forms;
10+
using Flow.Launcher.Core.Resource;
1011

1112
namespace Flow.Launcher.Core.ExternalPlugins.Environments
1213
{
@@ -50,14 +51,15 @@ internal IEnumerable<PluginPair> Setup()
5051
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
5152
}
5253

53-
if (MessageBox.Show($"Flow detected you have installed {Language} plugins, which " +
54-
$"will require {EnvName} to run. Would you like to download {EnvName}? " +
55-
Environment.NewLine + Environment.NewLine +
56-
"Click no if it's already installed, " +
57-
$"and you will be prompted to select the folder that contains the {EnvName} executable",
58-
string.Empty, MessageBoxButtons.YesNo) == DialogResult.No)
54+
var noRuntimeMessage = string.Format(
55+
InternationalizationManager.Instance.GetTranslation("runtimePluginInstalledChooseRuntimePrompt"),
56+
Language,
57+
EnvName,
58+
Environment.NewLine
59+
);
60+
if (MessageBox.Show(noRuntimeMessage, string.Empty, MessageBoxButtons.YesNo) == DialogResult.No)
5961
{
60-
var msg = $"Please select the {EnvName} executable";
62+
var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
6163
string selectedFile;
6264

6365
selectedFile = GetFileFromDialog(msg, FileDialogFilter);
@@ -80,8 +82,7 @@ internal IEnumerable<PluginPair> Setup()
8082
}
8183
else
8284
{
83-
MessageBox.Show(
84-
$"Unable to set {Language} executable path, please try from Flow's settings (scroll down to the bottom).");
85+
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
8586
Log.Error("PluginsLoader",
8687
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
8788
$"{Language}Environment");

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using ISavable = Flow.Launcher.Plugin.ISavable;
1414
using Flow.Launcher.Plugin.SharedCommands;
1515
using System.Text.Json;
16+
using Flow.Launcher.Core.Resource;
1617

1718
namespace Flow.Launcher.Core.Plugin
1819
{
@@ -160,6 +161,9 @@ public static async Task InitializePluginsAsync(IPublicAPI api)
160161
}
161162
}
162163

164+
InternationalizationManager.Instance.AddPluginLanguageDirectories();
165+
InternationalizationManager.Instance.ChangeLanguage(InternationalizationManager.Instance.Settings.Language);
166+
163167
if (failedPlugins.Any())
164168
{
165169
var failed = string.Join(",", failedPlugins.Select(x => x.Metadata.Name));

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class Internationalization
2525

2626
public Internationalization()
2727
{
28-
AddPluginLanguageDirectories();
2928
LoadDefaultLanguage();
3029
// we don't want to load /Languages/en.xaml twice
3130
// so add flowlauncher language directory after load plugin language files
@@ -40,7 +39,7 @@ private void AddFlowLauncherLanguageDirectory()
4039
}
4140

4241

43-
private void AddPluginLanguageDirectories()
42+
internal void AddPluginLanguageDirectories()
4443
{
4544
foreach (var plugin in PluginManager.GetPluginsForInterface<IPluginI18n>())
4645
{

Flow.Launcher/App.xaml.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
7171
StringMatcher.Instance = _stringMatcher;
7272
_stringMatcher.UserSettingSearchPrecision = _settings.QuerySearchPrecision;
7373

74+
InternationalizationManager.Instance.Settings = _settings;
75+
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
76+
7477
PluginManager.LoadPlugins(_settings.PluginSettings);
7578
_mainVM = new MainViewModel(_settings);
7679

@@ -89,11 +92,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
8992
Current.MainWindow = window;
9093
Current.MainWindow.Title = Constant.FlowLauncher;
9194

92-
// todo temp fix for instance code logic
93-
// load plugin before change language, because plugin language also needs be changed
94-
InternationalizationManager.Instance.Settings = _settings;
95-
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
96-
9795
HotKeyMapper.Initialize(_mainVM);
9896

9997
// main windows needs initialized before theme change because of blur settings

Flow.Launcher/Languages/en.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:system="clr-namespace:System;assembly=mscorlib">
5+
<!-- Startup -->
6+
<system:String x:Key="runtimePluginInstalledChooseRuntimePrompt">
7+
Flow detected you have installed {0} plugins, which will require {1} to run. Would you like to download {1}?
8+
{2}{2}
9+
Click no if it's already installed, and you will be prompted to select the folder that contains the {1} executable
10+
</system:String>
11+
<system:String x:Key="runtimePluginChooseRuntimeExecutable">Please select the {0} executable</system:String>
12+
<system:String x:Key="runtimePluginUnableToSetExecutablePath">Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom).</system:String>
13+
514
<!-- MainWindow -->
615
<system:String x:Key="registerHotkeyFailed">Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program.</system:String>
716
<system:String x:Key="MessageBoxTitle">Flow Launcher</system:String>

Flow.Launcher/Languages/ru.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:system="clr-namespace:System;assembly=mscorlib">
6+
<!-- Startup -->
7+
<system:String x:Key="runtimePluginInstalledChooseRuntimePrompt">
8+
Flow определил, что вы установили {0} плагины, которым требуется {1} для работы. Скачать {1}?
9+
{2}{2}
10+
Кликните нет, если он уже установлен, и вам будет предложено выбрать папку, где находится исполняемый файл {1}
11+
</system:String>
12+
<system:String x:Key="runtimePluginChooseRuntimeExecutable">Please select the {0} executable</system:String>
13+
<system:String x:Key="runtimePluginUnableToSetExecutablePath">Unable to set {0} executable path, please try from Flow's settings (scroll down to the bottom).</system:String>
614
<!-- MainWindow -->
715
<system:String x:Key="registerHotkeyFailed">Не удалось зарегистрировать сочетание клавиш &quot;{0}&quot;. Возможно, оно используется другой программой. Измените сочетание клавиш или закройте другую программу.</system:String>
816
<system:String x:Key="MessageBoxTitle">Flow Launcher</system:String>

0 commit comments

Comments
 (0)