Skip to content

Commit 01ca2e0

Browse files
committed
fix CommandBar localization. closes #2226
1 parent e434f47 commit 01ca2e0

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

RetailCoder.VBE/App.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Windows.Forms;
1212
using Rubberduck.Inspections.Resources;
1313
using Rubberduck.UI.Command;
14-
using Rubberduck.UI.Command.MenuItems.CommandBars;
1514
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
1615
using Rubberduck.VersionCheck;
1716
using Application = System.Windows.Forms.Application;
@@ -24,7 +23,6 @@ public sealed class App : IDisposable
2423
private readonly AutoSave.AutoSave _autoSave;
2524
private readonly IGeneralConfigService _configService;
2625
private readonly IAppMenu _appMenus;
27-
private readonly RubberduckCommandBar _stateBar;
2826
private readonly IRubberduckHooks _hooks;
2927
private readonly IVersionCheck _version;
3028
private readonly CommandBase _checkVersionCommand;
@@ -37,7 +35,6 @@ public App(IVBE vbe,
3735
IMessageBox messageBox,
3836
IGeneralConfigService configService,
3937
IAppMenu appMenus,
40-
RubberduckCommandBar stateBar,
4138
IRubberduckHooks hooks,
4239
IVersionCheck version,
4340
CommandBase checkVersionCommand)
@@ -46,7 +43,6 @@ public App(IVBE vbe,
4643
_configService = configService;
4744
_autoSave = new AutoSave.AutoSave(vbe, _configService);
4845
_appMenus = appMenus;
49-
_stateBar = stateBar;
5046
_hooks = hooks;
5147
_version = version;
5248
_checkVersionCommand = checkVersionCommand;
@@ -62,7 +58,6 @@ private void _configService_SettingsChanged(object sender, ConfigurationChangedE
6258
_hooks.HookHotkeys();
6359
// also updates the ShortcutKey text
6460
_appMenus.Localize();
65-
_stateBar.Localize();
6661
UpdateLoggingLevel();
6762

6863
if (e.LanguageChanged)
@@ -98,7 +93,6 @@ public void Startup()
9893
LoadConfig();
9994
CheckForLegacyIndenterSettings();
10095
_appMenus.Initialize();
101-
_stateBar.Initialize();
10296
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
10397
_appMenus.Localize();
10498

@@ -134,7 +128,6 @@ private void LoadConfig()
134128
RubberduckUI.Culture = CultureInfo.CurrentUICulture;
135129
InspectionsUI.Culture = CultureInfo.CurrentUICulture;
136130
_appMenus.Localize();
137-
_stateBar.Localize();
138131
}
139132
catch (CultureNotFoundException exception)
140133
{

RetailCoder.VBE/AppMenu.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Rubberduck.Parsing.VBA;
66
using Rubberduck.UI;
77
using Rubberduck.UI.Command.MenuItems;
8+
using Rubberduck.UI.Command.MenuItems.CommandBars;
89
using Rubberduck.UI.Command.MenuItems.ParentMenus;
910

1011
namespace Rubberduck
@@ -14,19 +15,22 @@ public class AppMenu : IAppMenu, IDisposable
1415
private readonly IReadOnlyList<IParentMenuItem> _menus;
1516
private readonly IParseCoordinator _parser;
1617
private readonly ISelectionChangeService _selectionService;
18+
private readonly RubberduckCommandBar _stateBar;
1719

18-
public AppMenu(IEnumerable<IParentMenuItem> menus, IParseCoordinator parser, ISelectionChangeService selectionService)
20+
public AppMenu(IEnumerable<IParentMenuItem> menus, IParseCoordinator parser, ISelectionChangeService selectionService, RubberduckCommandBar stateBar)
1921
{
2022
_menus = menus.ToList();
2123
_parser = parser;
2224
_selectionService = selectionService;
25+
_stateBar = stateBar;
2326

2427
_parser.State.StateChanged += OnParserStateChanged;
2528
_selectionService.SelectedDeclarationChanged += OnSelectedDeclarationChange;
2629
}
2730

2831
public void Initialize()
2932
{
33+
_stateBar.Initialize();
3034
foreach (var menu in _menus)
3135
{
3236
menu.Initialize();
@@ -53,6 +57,8 @@ public void EvaluateCanExecute(RubberduckParserState state)
5357

5458
public void Localize()
5559
{
60+
_stateBar.Localize();
61+
_stateBar.SetStatusLabelCaption(_parser.State.Status);
5662
foreach (var menu in _menus)
5763
{
5864
menu.Localize();

RetailCoder.VBE/UI/Command/MenuItems/CommandBars/AppCommandBarBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected AppCommandBarBase(string name, CommandBarPosition position, IEnumerabl
2525

2626
protected ICommandMenuItem FindChildByTag(string tag)
2727
{
28-
var child = _items.FirstOrDefault(kvp => kvp.Value.Tag == tag);
28+
var child = _items.FirstOrDefault(kvp => kvp.Value != null && kvp.Value.Tag == tag);
2929
return Equals(child, default(KeyValuePair<ICommandMenuItem, ICommandBarControl>))
3030
? null
3131
: child.Key;

RetailCoder.VBE/UI/Command/MenuItems/CommandBars/RubberduckCommandBar.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using Rubberduck.Parsing;
56
using Rubberduck.Parsing.Symbols;
@@ -91,7 +92,7 @@ private void OnParserStateChanged(object sender, EventArgs e)
9192

9293
public void SetStatusLabelCaption(ParserState state, int? errorCount = null)
9394
{
94-
var caption = RubberduckUI.ResourceManager.GetString("ParserState_" + state, Settings.Settings.Culture);
95+
var caption = RubberduckUI.ResourceManager.GetString("ParserState_" + state, CultureInfo.CurrentUICulture);
9596
SetStatusLabelCaption(caption, errorCount);
9697
}
9798

0 commit comments

Comments
 (0)