diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index 29f0519c0..7bf5a17b5 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -407,9 +407,6 @@ namespace Greenshot { coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor; coreConfiguration.UpdateCheckInterval = (int)numericUpDown_daysbetweencheck.Value; - // Make sure the current language & settings are reflected in the Main-context menu - MainForm.Instance.UpdateUI(); - try { // Check if the Run for all is set if(!StartupHelper.checkRunAll()) { @@ -438,6 +435,9 @@ namespace Greenshot { SaveSettings(); StoreFields(); MainForm.RegisterHotkeys(); + + // Make sure the current language & settings are reflected in the Main-context menu + MainForm.Instance.UpdateUI(); DialogResult = DialogResult.OK; } else { this.tabcontrol.SelectTab(this.tab_output); diff --git a/GreenshotBoxPlugin/BoxPlugin.cs b/GreenshotBoxPlugin/BoxPlugin.cs index 07f0bdbb2..5945c5259 100644 --- a/GreenshotBoxPlugin/BoxPlugin.cs +++ b/GreenshotBoxPlugin/BoxPlugin.cs @@ -39,6 +39,7 @@ namespace GreenshotBoxPlugin { public static PluginAttribute Attributes; private IGreenshotHost host; private ComponentResourceManager resources; + private ToolStripMenuItem itemPlugInConfig; public BoxPlugin() { } @@ -65,16 +66,22 @@ namespace GreenshotBoxPlugin { config = IniConfig.GetIniSection(); resources = new ComponentResourceManager(typeof(BoxPlugin)); - ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(); + itemPlugInConfig = new ToolStripMenuItem(); itemPlugInConfig.Image = (Image)resources.GetObject("Box"); itemPlugInConfig.Text = Language.GetString("box", LangKey.Configure); itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick); PluginUtils.AddToContextMenu(host, itemPlugInConfig); - + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return true; } + public void OnLanguageChanged() { + if (itemPlugInConfig != null) { + itemPlugInConfig.Text = Language.GetString("box", LangKey.Configure); + } + } + public virtual void Shutdown() { LOG.Debug("Box Plugin shutdown."); } diff --git a/GreenshotDropboxPlugin/DropboxPlugin.cs b/GreenshotDropboxPlugin/DropboxPlugin.cs index c3233cc72..766f9c626 100644 --- a/GreenshotDropboxPlugin/DropboxPlugin.cs +++ b/GreenshotDropboxPlugin/DropboxPlugin.cs @@ -39,6 +39,7 @@ namespace GreenshotDropboxPlugin { public static PluginAttribute Attributes; private IGreenshotHost host; private ComponentResourceManager resources; + private ToolStripMenuItem itemPlugInConfig; public DropboxPlugin() { } @@ -65,17 +66,23 @@ namespace GreenshotDropboxPlugin { config = IniConfig.GetIniSection(); resources = new ComponentResourceManager(typeof(DropboxPlugin)); - ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(); + itemPlugInConfig = new ToolStripMenuItem(); itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure); itemPlugInConfig.Tag = host; itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick); itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox"); PluginUtils.AddToContextMenu(host, itemPlugInConfig); - + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return true; } + public void OnLanguageChanged() { + if (itemPlugInConfig != null) { + itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure); + } + } + public virtual void Shutdown() { LOG.Debug("Dropbox Plugin shutdown."); } diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs index 6c9e4dc97..d0bd8c56f 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs @@ -35,6 +35,7 @@ namespace ExternalCommand { private static ExternalCommandConfiguration config = IniConfig.GetIniSection(); private IGreenshotHost host; private PluginAttribute myAttributes; + private ToolStripMenuItem itemPlugInRoot; public ExternalCommandPlugin() { } @@ -68,7 +69,7 @@ namespace ExternalCommand { this.myAttributes = myAttributes; - ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem(); + itemPlugInRoot = new ToolStripMenuItem(); itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure"); itemPlugInRoot.Tag = host; string exePath = PluginUtils.GetExePath("cmd.exe"); @@ -78,9 +79,16 @@ namespace ExternalCommand { itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick); PluginUtils.AddToContextMenu(host, itemPlugInRoot); + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return true; } + public void OnLanguageChanged() { + if (itemPlugInRoot != null) { + itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure"); + } + } + public virtual void Shutdown() { LOG.Debug("Shutdown of " + myAttributes.Name); } diff --git a/GreenshotFlickrPlugin/FlickrPlugin.cs b/GreenshotFlickrPlugin/FlickrPlugin.cs index b5090b715..c0ebc4da3 100644 --- a/GreenshotFlickrPlugin/FlickrPlugin.cs +++ b/GreenshotFlickrPlugin/FlickrPlugin.cs @@ -40,6 +40,7 @@ namespace GreenshotFlickrPlugin public static PluginAttribute Attributes; private IGreenshotHost host; private ComponentResourceManager resources; + private ToolStripMenuItem itemPlugInConfig; public FlickrPlugin() { } @@ -67,17 +68,23 @@ namespace GreenshotFlickrPlugin config = IniConfig.GetIniSection(); resources = new ComponentResourceManager(typeof(FlickrPlugin)); - ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(); + itemPlugInConfig = new ToolStripMenuItem(); itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure); itemPlugInConfig.Tag = host; itemPlugInConfig.Image = (Image)resources.GetObject("flickr"); itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick); PluginUtils.AddToContextMenu(host, itemPlugInConfig); - + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return true; } + public void OnLanguageChanged() { + if (itemPlugInConfig != null) { + itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure); + } + } + public virtual void Shutdown() { LOG.Debug("Flickr Plugin shutdown."); } diff --git a/GreenshotImgurPlugin/ImgurPlugin.cs b/GreenshotImgurPlugin/ImgurPlugin.cs index cf2977190..c5ace12af 100644 --- a/GreenshotImgurPlugin/ImgurPlugin.cs +++ b/GreenshotImgurPlugin/ImgurPlugin.cs @@ -41,6 +41,7 @@ namespace GreenshotImgurPlugin { private IGreenshotHost host; private ComponentResourceManager resources; private ToolStripMenuItem historyMenuItem = null; + private ToolStripMenuItem itemPlugInConfig; public ImgurPlugin() { } @@ -78,7 +79,7 @@ namespace GreenshotImgurPlugin { }; itemPlugInRoot.DropDownItems.Add(historyMenuItem); - ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure)); + itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure)); itemPlugInConfig.Tag = host; itemPlugInConfig.Click += delegate { config.ShowConfigDialog(); @@ -86,6 +87,7 @@ namespace GreenshotImgurPlugin { itemPlugInRoot.DropDownItems.Add(itemPlugInConfig); PluginUtils.AddToContextMenu(host, itemPlugInRoot); + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); // retrieve history in the background Thread backgroundTask = new Thread (new ThreadStart(CheckHistory)); @@ -95,7 +97,16 @@ namespace GreenshotImgurPlugin { backgroundTask.Start(); return true; } - + + public void OnLanguageChanged() { + if (itemPlugInConfig != null) { + itemPlugInConfig.Text = Language.GetString("imgur", LangKey.configure); + } + if (historyMenuItem != null) { + historyMenuItem.Text = Language.GetString("imgur", LangKey.history); + } + } + private void CheckHistory() { try { ImgurUtils.LoadHistory(); diff --git a/GreenshotPicasaPlugin/PicasaPlugin.cs b/GreenshotPicasaPlugin/PicasaPlugin.cs index 5302daa7a..0af75c7ac 100644 --- a/GreenshotPicasaPlugin/PicasaPlugin.cs +++ b/GreenshotPicasaPlugin/PicasaPlugin.cs @@ -38,6 +38,7 @@ namespace GreenshotPicasaPlugin { public static PluginAttribute Attributes; private IGreenshotHost host; private ComponentResourceManager resources; + private ToolStripMenuItem itemPlugInRoot; public PicasaPlugin() { } @@ -65,18 +66,25 @@ namespace GreenshotPicasaPlugin { config = IniConfig.GetIniSection(); resources = new ComponentResourceManager(typeof(PicasaPlugin)); - ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem(); + itemPlugInRoot = new ToolStripMenuItem(); itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure); itemPlugInRoot.Tag = host; itemPlugInRoot.Image = (Image)resources.GetObject("Picasa"); itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick); PluginUtils.AddToContextMenu(host, itemPlugInRoot); - + Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged); return true; } + public void OnLanguageChanged() { + if (itemPlugInRoot != null) { + itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure); + } + } + public virtual void Shutdown() { LOG.Debug("Picasa Plugin shutdown."); + Language.LanguageChanged -= new LanguageChangedHandler(OnLanguageChanged); //host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened); } diff --git a/GreenshotPlugin/Core/Language.cs b/GreenshotPlugin/Core/Language.cs index 95c55bb56..30e2e4238 100644 --- a/GreenshotPlugin/Core/Language.cs +++ b/GreenshotPlugin/Core/Language.cs @@ -28,6 +28,7 @@ using Greenshot.IniFile; using Microsoft.Win32; namespace GreenshotPlugin.Core { + public delegate void LanguageChangedHandler(); /// /// This class supplies the GUI with translations, based upon keys. /// The language resources are loaded from the language files found on fixed or supplied paths @@ -49,6 +50,8 @@ namespace GreenshotPlugin.Core { private static string currentLanguage = null; private static CoreConfiguration coreConfig = null; + public static event LanguageChangedHandler LanguageChanged; + /// /// Static initializer for the language code /// @@ -197,6 +200,12 @@ namespace GreenshotPlugin.Core { if (currentLanguage == null || !currentLanguage.Equals(ietf)) { currentLanguage = ietf; Reload(); + if (LanguageChanged != null) { + try { + LanguageChanged(); + } catch { + } + } return; } }