Skip to content

Commit 920668d

Browse files
authored
Merge pull request #223 from taooceros/fixTrayMenuTranslation
fix tray menu translation
2 parents 6514c13 + ac6dea1 commit 920668d

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ public void ChangeLanguage(Language language)
8888
{
8989
language = language.NonNull();
9090

91-
Settings.Language = language.LanguageCode;
9291

9392
RemoveOldLanguageFiles();
9493
if (language != AvailableLanguages.English)
9594
{
9695
LoadLanguage(language);
9796
}
9897
UpdatePluginMetadataTranslations();
98+
Settings.Language = language.LanguageCode;
9999

100100
}
101101

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
99
{
1010
public class Settings : BaseModel
1111
{
12+
private string language = "en";
13+
1214
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
1315
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
1416
public bool ShowOpenResultHotkey { get; set; } = true;
15-
public string Language { get; set; } = "en";
17+
public string Language
18+
{
19+
get => language; set {
20+
language = value;
21+
OnPropertyChanged();
22+
}
23+
}
1624
public string Theme { get; set; } = Constant.DefaultTheme;
1725
public bool UseDropShadowEffect { get; set; } = false;
1826
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ private void OnClosing(object sender, CancelEventArgs e)
5252

5353
private void OnInitialized(object sender, EventArgs e)
5454
{
55-
// show notify icon when flowlauncher is hided
56-
InitializeNotifyIcon();
55+
5756
}
5857

5958
private void OnLoaded(object sender, RoutedEventArgs _)
6059
{
60+
// show notify icon when flowlauncher is hidden
61+
InitializeNotifyIcon();
62+
6163
// todo is there a way to set blur only once?
6264
ThemeManager.Instance.SetBlurForWindow();
6365
WindowsInteropHelper.DisableControlBox(this);
@@ -87,11 +89,17 @@ private void OnLoaded(object sender, RoutedEventArgs _)
8789
};
8890
_settings.PropertyChanged += (o, e) =>
8991
{
90-
if (e.PropertyName == nameof(Settings.HideNotifyIcon))
92+
switch (e.PropertyName)
9193
{
92-
_notifyIcon.Visible = !_settings.HideNotifyIcon;
94+
case nameof(Settings.HideNotifyIcon):
95+
_notifyIcon.Visible = !_settings.HideNotifyIcon;
96+
break;
97+
case nameof(Settings.Language):
98+
UpdateNotifyIconText();
99+
break;
93100
}
94101
};
102+
95103
InitializePosition();
96104
}
97105

@@ -103,6 +111,18 @@ private void InitializePosition()
103111
_settings.WindowLeft = Left;
104112
}
105113

114+
private void UpdateNotifyIconText()
115+
{
116+
var menu = _notifyIcon.ContextMenuStrip;
117+
var open = menu.Items[0];
118+
var setting = menu.Items[1];
119+
var exit = menu.Items[2];
120+
121+
open.Text = InternationalizationManager.Instance.GetTranslation("iconTrayOpen");
122+
setting.Text = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
123+
exit.Text = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
124+
}
125+
106126
private void InitializeNotifyIcon()
107127
{
108128
_notifyIcon = new NotifyIcon
@@ -179,7 +199,6 @@ private void OnPreviewMouseButtonDown(object sender, MouseButtonEventArgs e)
179199
}
180200
}
181201

182-
183202
private void OnDrop(object sender, DragEventArgs e)
184203
{
185204
if (e.Data.GetDataPresent(DataFormats.FileDrop))
@@ -294,7 +313,5 @@ private void OnTextChanged(object sender, TextChangedEventArgs e)
294313
_viewModel.QueryTextCursorMovedToEnd = false;
295314
}
296315
}
297-
298-
299316
}
300317
}

0 commit comments

Comments
 (0)