Fixed language synchronizing over Greenshot and the plugins

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1741 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-02 16:56:03 +00:00
parent ee950872e9
commit 59f9922670
16 changed files with 116 additions and 102 deletions

View file

@ -31,13 +31,10 @@ namespace GreenshotOCR {
private const string LANGUAGE_FILENAME_PATTERN = @"language_ocrplugin-*.xml"; private const string LANGUAGE_FILENAME_PATTERN = @"language_ocrplugin-*.xml";
public static ILanguage GetInstance() { public static ILanguage GetInstance() {
if(uniqueInstance == null) { if (uniqueInstance == null) {
uniqueInstance = new LanguageContainer(); uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
} }
return uniqueInstance; return uniqueInstance;
} }
} }
} }

View file

@ -37,7 +37,6 @@ namespace GreenshotOCR {
this.config = config; this.config = config;
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
language.SynchronizeLanguageToCulture();
initializeComponentText(); initializeComponentText();
comboBox_languages.Items.Clear(); comboBox_languages.Items.Clear();

View file

@ -41,9 +41,9 @@ namespace Greenshot.Configuration {
uniqueInstance.Load(); uniqueInstance.Load();
CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>(); CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
if (string.IsNullOrEmpty(conf.Language)) { if (string.IsNullOrEmpty(conf.Language)) {
uniqueInstance.SynchronizeLanguageToCulture(); LanguageContainer.SynchronizeLanguageToCulture();
} else { } else {
uniqueInstance.SetLanguage(conf.Language); LanguageContainer.SetGlobalLanguage(conf.Language);
} }
if (freeResources) { if (freeResources) {
uniqueInstance.FreeResources(); uniqueInstance.FreeResources();

View file

@ -77,7 +77,7 @@ namespace Greenshot.Forms {
// But the use-case is not so interesting, only happens once, to invest a lot of time here. // But the use-case is not so interesting, only happens once, to invest a lot of time here.
if (language.SupportedLanguages.Count == 1) { if (language.SupportedLanguages.Count == 1) {
this.comboBoxLanguage.SelectedValue = language.SupportedLanguages[0].Ietf; this.comboBoxLanguage.SelectedValue = language.SupportedLanguages[0].Ietf;
language.SetLanguage(SelectedLanguage); LanguageContainer.SetGlobalLanguage(SelectedLanguage);
properOkPressed = true; properOkPressed = true;
this.Close(); this.Close();
} }
@ -86,7 +86,7 @@ namespace Greenshot.Forms {
void BtnOKClick(object sender, EventArgs e) { void BtnOKClick(object sender, EventArgs e) {
properOkPressed = true; properOkPressed = true;
// Fix for Bug #3431100 // Fix for Bug #3431100
language.SetLanguage(SelectedLanguage); LanguageContainer.SetGlobalLanguage(SelectedLanguage);
this.Close(); this.Close();
} }

View file

@ -431,7 +431,7 @@ namespace Greenshot {
/// <param name="e"></param> /// <param name="e"></param>
private void ReloadConfiguration(object source, FileSystemEventArgs e) { private void ReloadConfiguration(object source, FileSystemEventArgs e) {
lang.Load(); lang.Load();
lang.SetLanguage(conf.Language); LanguageContainer.SetGlobalLanguage(conf.Language);
lang.FreeResources(); lang.FreeResources();
this.Invoke((MethodInvoker) delegate { this.Invoke((MethodInvoker) delegate {
// Even update language when needed // Even update language when needed

View file

@ -72,7 +72,7 @@ namespace Greenshot {
this.groupbox_destination = new System.Windows.Forms.GroupBox(); this.groupbox_destination = new System.Windows.Forms.GroupBox();
this.checkbox_picker = new System.Windows.Forms.CheckBox(); this.checkbox_picker = new System.Windows.Forms.CheckBox();
this.destinationsListView = new System.Windows.Forms.ListView(); this.destinationsListView = new System.Windows.Forms.ListView();
this.destination = new System.Windows.Forms.ColumnHeader(); this.destination = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabcontrol = new System.Windows.Forms.TabControl(); this.tabcontrol = new System.Windows.Forms.TabControl();
this.tab_general = new System.Windows.Forms.TabPage(); this.tab_general = new System.Windows.Forms.TabPage();
this.groupbox_network = new System.Windows.Forms.GroupBox(); this.groupbox_network = new System.Windows.Forms.GroupBox();
@ -374,7 +374,7 @@ namespace Greenshot {
this.destinationsListView.AutoArrange = false; this.destinationsListView.AutoArrange = false;
this.destinationsListView.CheckBoxes = true; this.destinationsListView.CheckBoxes = true;
this.destinationsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.destinationsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.destination}); this.destination});
this.destinationsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.destinationsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.destinationsListView.LabelWrap = false; this.destinationsListView.LabelWrap = false;
this.destinationsListView.Location = new System.Drawing.Point(6, 38); this.destinationsListView.Location = new System.Drawing.Point(6, 38);
@ -701,16 +701,16 @@ namespace Greenshot {
// numericUpDownWaitTime // numericUpDownWaitTime
// //
this.numericUpDownWaitTime.Increment = new decimal(new int[] { this.numericUpDownWaitTime.Increment = new decimal(new int[] {
100, 100,
0, 0,
0, 0,
0}); 0});
this.numericUpDownWaitTime.Location = new System.Drawing.Point(11, 69); this.numericUpDownWaitTime.Location = new System.Drawing.Point(11, 69);
this.numericUpDownWaitTime.Maximum = new decimal(new int[] { this.numericUpDownWaitTime.Maximum = new decimal(new int[] {
10000, 10000,
0, 0,
0, 0,
0}); 0});
this.numericUpDownWaitTime.Name = "numericUpDownWaitTime"; this.numericUpDownWaitTime.Name = "numericUpDownWaitTime";
this.numericUpDownWaitTime.Size = new System.Drawing.Size(57, 20); this.numericUpDownWaitTime.Size = new System.Drawing.Size(57, 20);
this.numericUpDownWaitTime.TabIndex = 24; this.numericUpDownWaitTime.TabIndex = 24;
@ -868,8 +868,8 @@ namespace Greenshot {
// groupbox_plugins // groupbox_plugins
// //
this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupbox_plugins.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.groupbox_plugins.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.groupbox_plugins.Controls.Add(this.listview_plugins); this.groupbox_plugins.Controls.Add(this.listview_plugins);
this.groupbox_plugins.Controls.Add(this.button_pluginconfigure); this.groupbox_plugins.Controls.Add(this.button_pluginconfigure);

View file

@ -228,6 +228,9 @@ namespace Greenshot {
this.label_region_hotkey.Text = lang.GetString(LangKey.contextmenu_capturearea); this.label_region_hotkey.Text = lang.GetString(LangKey.contextmenu_capturearea);
this.label_window_hotkey.Text = lang.GetString(LangKey.contextmenu_capturewindow); this.label_window_hotkey.Text = lang.GetString(LangKey.contextmenu_capturewindow);
// Removing, otherwise we keep getting the event multiple times!
this.combobox_language.SelectedIndexChanged -= new System.EventHandler(this.Combobox_languageSelectedIndexChanged);
// Initialize the Language ComboBox // Initialize the Language ComboBox
this.combobox_language.DisplayMember = "Description"; this.combobox_language.DisplayMember = "Description";
this.combobox_language.ValueMember = "Ietf"; this.combobox_language.ValueMember = "Ietf";
@ -240,6 +243,7 @@ namespace Greenshot {
// Delaying the SelectedIndexChanged events untill all is initiated // Delaying the SelectedIndexChanged events untill all is initiated
this.combobox_language.SelectedIndexChanged += new System.EventHandler(this.Combobox_languageSelectedIndexChanged); this.combobox_language.SelectedIndexChanged += new System.EventHandler(this.Combobox_languageSelectedIndexChanged);
UpdateDestinations();
} }
// Check the settings and somehow visibly mark when something is incorrect // Check the settings and somehow visibly mark when something is incorrect
@ -254,6 +258,50 @@ namespace Greenshot {
return settingsOk; return settingsOk;
} }
private void UpdateDestinations() {
foreach (ListViewItem item in destinationsListView.Items) {
IDestination destination = item.Tag as IDestination;
item.Text = destination.Description;
}
}
private void DisplayDestinations() {
checkbox_picker.Checked = false;
destinationsListView.Items.Clear();
destinationsListView.ListViewItemSorter = new ListviewWithDestinationComparer();
ImageList imageList = new ImageList();
destinationsListView.SmallImageList = imageList;
int imageNr = -1;
foreach (IDestination destination in DestinationHelper.GetAllDestinations()) {
Image destinationImage = destination.DisplayIcon;
if (destinationImage != null) {
imageList.Images.Add(destination.DisplayIcon);
imageNr++;
}
if (PickerDestination.DESIGNATION.Equals(destination.Designation)) {
checkbox_picker.Checked = true;
checkbox_picker.Text = destination.Description;
} else {
ListViewItem item;
if (destinationImage != null) {
item = destinationsListView.Items.Add(destination.Description, imageNr);
} else {
item = destinationsListView.Items.Add(destination.Description);
}
item.Tag = destination;
item.Checked = coreConfiguration.OutputDestinations.Contains(destination.Designation);
}
}
if (checkbox_picker.Checked) {
destinationsListView.Enabled = false;
foreach (int index in destinationsListView.CheckedIndices) {
ListViewItem item = destinationsListView.Items[index];
item.Checked = false;
}
}
}
private void DisplaySettings() { private void DisplaySettings() {
region_hotkeyControl.SetHotkey(coreConfiguration.RegionHotkey); region_hotkeyControl.SetHotkey(coreConfiguration.RegionHotkey);
fullscreen_hotkeyControl.SetHotkey(coreConfiguration.FullscreenHotkey); fullscreen_hotkeyControl.SetHotkey(coreConfiguration.FullscreenHotkey);
@ -278,40 +326,8 @@ namespace Greenshot {
checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality; checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality;
checkbox_playsound.Checked = coreConfiguration.PlayCameraSound; checkbox_playsound.Checked = coreConfiguration.PlayCameraSound;
checkbox_picker.Checked = false; DisplayDestinations();
destinationsListView.Items.Clear();
destinationsListView.ListViewItemSorter = new ListviewWithDestinationComparer();
ImageList imageList = new ImageList();
destinationsListView.SmallImageList = imageList;
int imageNr = -1;
foreach(IDestination destination in DestinationHelper.GetAllDestinations()) {
Image destinationImage = destination.DisplayIcon;
if (destinationImage != null) {
imageList.Images.Add(destination.DisplayIcon);
imageNr++;
}
if (PickerDestination.DESIGNATION.Equals(destination.Designation)) {
checkbox_picker.Checked = true;
checkbox_picker.Text = destination.Description;
} else {
ListViewItem item;
if (destinationImage != null) {
item = destinationsListView.Items.Add(destination.Description, imageNr);
} else {
item = destinationsListView.Items.Add(destination.Description);
}
item.Tag = destination;
item.Checked = coreConfiguration.OutputDestinations.Contains(destination.Designation);
}
}
if (checkbox_picker.Checked) {
destinationsListView.Enabled = false;
foreach(int index in destinationsListView.CheckedIndices) {
ListViewItem item = destinationsListView.Items[index];
item.Checked = false;
}
}
// checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard"); // checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard");
// checkbox_file.Checked = coreConfiguration.OutputDestinations.Contains("File"); // checkbox_file.Checked = coreConfiguration.OutputDestinations.Contains("File");
// checkbox_fileas.Checked = coreConfiguration.OutputDestinations.Contains("FileWithDialog"); // checkbox_fileas.Checked = coreConfiguration.OutputDestinations.Contains("FileWithDialog");
@ -487,7 +503,7 @@ namespace Greenshot {
WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode); WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
if (combobox_language.SelectedItem != null) { if (combobox_language.SelectedItem != null) {
LOG.Debug("Setting language to: " + (string)combobox_language.SelectedValue); LOG.Debug("Setting language to: " + (string)combobox_language.SelectedValue);
lang.SetLanguage((string)combobox_language.SelectedValue); LanguageContainer.SetGlobalLanguage((string)combobox_language.SelectedValue);
} }
// Reflect language changes to the settings form // Reflect language changes to the settings form
UpdateUI(); UpdateUI();

View file

@ -263,7 +263,7 @@ Sie können alle Greenshot-Funktionen aber auch über das Kontextmenü des Green
In Zwischenablage kopieren In Zwischenablage kopieren
</resource> </resource>
<resource name="settings_destination_picker"> <resource name="settings_destination_picker">
Ziel auswählen Ziel dynamisch auswählen
</resource> </resource>
<resource name="editor_drawline"> <resource name="editor_drawline">
Linie zeichnen (L) Linie zeichnen (L)

View file

@ -268,7 +268,7 @@ All Greenshot features still work directly from the tray icon context menu witho
Copy to clipboard Copy to clipboard
</resource> </resource>
<resource name="settings_destination_picker"> <resource name="settings_destination_picker">
Select destination Select destination dynamically
</resource> </resource>
<resource name="editor_drawline"> <resource name="editor_drawline">
Draw line (L) Draw line (L)

View file

@ -258,7 +258,7 @@ Alle Greenshot functies werken ook over het context menu.
Kopieer naar klembord Kopieer naar klembord
</resource> </resource>
<resource name="settings_destination_picker"> <resource name="settings_destination_picker">
Doel kiezen Dynamisch het doel kiezen
</resource> </resource>
<resource name="editor_drawline"> <resource name="editor_drawline">
Lijn tekenen (L) Lijn tekenen (L)

View file

@ -3,9 +3,9 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a
CHANGE LOG: CHANGE LOG:
0.9.0 Build 1714 1.0.0 build 1740
We changed the version to 0.9.0 as the amount of features in 0.8.1 was more than planned. We changed the version to 1.0.0, after 5 year the version should no longer have a "beta" feeling!
Bugs resolved: Bugs resolved:
* Fixed a problem with the window preview, if the window had a small height, when using the context menu (Windows Vista and later) * Fixed a problem with the window preview, if the window had a small height, when using the context menu (Windows Vista and later)
@ -16,17 +16,20 @@ Bugs resolved:
* Fixed bug #3482709 print with timestamp cropped the image * Fixed bug #3482709 print with timestamp cropped the image
* Removed the always active CaptureForm, which resulted in greenshot not "recovering" when a capture caused an exception. * Removed the always active CaptureForm, which resulted in greenshot not "recovering" when a capture caused an exception.
* Improved the auto-capture mode to honor some settings better * Improved the auto-capture mode to honor some settings better
* Synchronized the selected language to the plugins
Features added: Features added:
* Greenshot will now run in 64 bit mode, if the OS supports it. * Greenshot will now run in 64 bit mode, if the OS supports it.
* Added a "destinations" concept, making it possible to select all destinations from the main settings or using them inside the editor. * Added a "destinations" concept, making it possible to select all destinations from the main settings or using them inside the editor.
* Added a "processor" concept, making it possible to modify the capture before it's send to a destination. Currently there is only an internal implementation which replaces the TitleFix plugin. * Added a "processor" concept, making it possible to modify the capture before it's send to a destination. Currently there is only an internal implementation which replaces the TitleFix plugin.
* Added Office destinations (Word, Excel, Powerpoint & Outlook) with dynamic resolving of open "instances". * Added Office destinations (Word, Excel, Powerpoint, OneNote & Outlook) with dynamic resolving of open "instances".
* Added Ctrl/shift logic to the editor, hard to explain (see help) but hold one of the keys down and draw.. * Added Ctrl/shift logic to the editor, hard to explain (see help) but hold one of the keys down and draw..
* Added a color picker in the color dialog. * Added a color picker in the color dialog.
* Added shadow & torn edges * Added effects: shadow, torn edges, invert, border and grayscale
* Added rotate clockwise & counter clockwise
* Added color reduction as an option and auto detection for image with less than 256 color. When using reduction this results in smaller files. * Added color reduction as an option and auto detection for image with less than 256 color. When using reduction this results in smaller files.
0.8.1 Build 1483 0.8.1 Build 1483
Bugs resolved: Bugs resolved:

View file

@ -32,12 +32,9 @@ namespace GreenshotConfluencePlugin {
public static ILanguage GetInstance() { public static ILanguage GetInstance() {
if(uniqueInstance == null) { if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer(); uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
} }
return uniqueInstance; return uniqueInstance;
} }
} }
} }

View file

@ -32,12 +32,9 @@ namespace GreenshotImgurPlugin {
public static ILanguage GetInstance() { public static ILanguage GetInstance() {
if(uniqueInstance == null) { if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer(); uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
} }
return uniqueInstance; return uniqueInstance;
} }
} }
} }

View file

@ -38,7 +38,6 @@ namespace GreenshotJiraPlugin {
public JiraForm(JiraConnector jiraConnector) { public JiraForm(JiraConnector jiraConnector) {
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
language.SynchronizeLanguageToCulture();
initializeComponentText(); initializeComponentText();
this.columnSorter = new ListViewColumnSorter(); this.columnSorter = new ListViewColumnSorter();

View file

@ -32,12 +32,9 @@ namespace GreenshotJiraPlugin {
public static ILanguage GetInstance() { public static ILanguage GetInstance() {
if(uniqueInstance == null) { if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer(); uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
} }
return uniqueInstance; return uniqueInstance;
} }
} }
} }

View file

@ -42,13 +42,6 @@ namespace GreenshotPlugin.Core {
string GetFormattedString(string id, object param); string GetFormattedString(string id, object param);
string GetHelpFilePath(); string GetHelpFilePath();
/// <summary>
/// Set language
/// </summary>
/// <param name="wantedIETF">wanted IETF</param>
/// <returns>Actuall IETF </returns>
string SetLanguage(string cultureInfo);
void SynchronizeLanguageToCulture();
void FreeResources(); void FreeResources();
string CurrentLanguage { string CurrentLanguage {
@ -81,12 +74,14 @@ namespace GreenshotPlugin.Core {
private static string PAF_LANGUAGE_PATH = Path.Combine(APPLICATION_PATH, @"App\Greenshot\Languages"); private static string PAF_LANGUAGE_PATH = Path.Combine(APPLICATION_PATH, @"App\Greenshot\Languages");
private const string HELP_FILENAME_PATTERN = @"help-*.html"; private const string HELP_FILENAME_PATTERN = @"help-*.html";
private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups"; private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups";
private static string globalLanguage = null;
private Dictionary<string, string> strings = new Dictionary<string, string>(); private Dictionary<string, string> strings = new Dictionary<string, string>();
private List<LanguageConfiguration> languages = new List<LanguageConfiguration>(); private List<LanguageConfiguration> languages = new List<LanguageConfiguration>();
private string currentIETF = null; private string currentIETF = null;
private string languageFilePattern; private string languageFilePattern;
private static List<string> supportedLanguageGroups = new List<string>(); private static List<string> supportedLanguageGroups = new List<string>();
private static List<LanguageContainer> instances = new List<LanguageContainer>();
static LanguageContainer() { static LanguageContainer() {
try { try {
@ -108,6 +103,13 @@ namespace GreenshotPlugin.Core {
} }
public LanguageContainer() { public LanguageContainer() {
instances.Add(this);
}
public LanguageContainer(string filePattern) : this() {
LanguageFilePattern = filePattern;
Load();
SetInstanceLanguage(globalLanguage);
} }
public String LanguageFilePattern { public String LanguageFilePattern {
@ -146,9 +148,16 @@ namespace GreenshotPlugin.Core {
} }
} }
public void SynchronizeLanguageToCulture() { public static void SynchronizeLanguageToCulture() {
if (CurrentLanguage == null || !CurrentLanguage.Equals(Thread.CurrentThread.CurrentUICulture.Name)) { if (globalLanguage == null || !globalLanguage.Equals(Thread.CurrentThread.CurrentUICulture.Name)) {
SetLanguage(Thread.CurrentThread.CurrentUICulture.Name); SetGlobalLanguage(Thread.CurrentThread.CurrentUICulture.Name);
}
}
public static void SetGlobalLanguage(string wantedIETF) {
globalLanguage = wantedIETF;
foreach (LanguageContainer langInstance in instances) {
langInstance.SetInstanceLanguage(wantedIETF);
} }
} }
@ -157,7 +166,7 @@ namespace GreenshotPlugin.Core {
/// </summary> /// </summary>
/// <param name="wantedIETF">wanted IETF</param> /// <param name="wantedIETF">wanted IETF</param>
/// <returns>Actuall IETF </returns> /// <returns>Actuall IETF </returns>
public string SetLanguage(string wantedIETF) { public string SetInstanceLanguage(string wantedIETF) {
LOG.Debug("SetLanguage called for : " + wantedIETF); LOG.Debug("SetLanguage called for : " + wantedIETF);
Dictionary<string, LanguageConfiguration> identifiedLanguages = new Dictionary<string, LanguageConfiguration>(); Dictionary<string, LanguageConfiguration> identifiedLanguages = new Dictionary<string, LanguageConfiguration>();
@ -176,9 +185,9 @@ namespace GreenshotPlugin.Core {
} }
LanguageConfiguration selectedLanguage = null; LanguageConfiguration selectedLanguage = null;
try { if (identifiedLanguages.ContainsKey(wantedIETF)) {
selectedLanguage = identifiedLanguages[wantedIETF]; selectedLanguage = identifiedLanguages[wantedIETF];
} catch (KeyNotFoundException) { } else {
LOG.Warn("Selecteded language " + wantedIETF + " not found."); LOG.Warn("Selecteded language " + wantedIETF + " not found.");
} }
@ -186,12 +195,12 @@ namespace GreenshotPlugin.Core {
if (selectedLanguage == null) { if (selectedLanguage == null) {
foreach(string ietf in identifiedLanguages.Keys) { foreach(string ietf in identifiedLanguages.Keys) {
if (ietf.StartsWith(wantedIETF)) { if (ietf.StartsWith(wantedIETF)) {
try { if (identifiedLanguages.ContainsKey(ietf)) {
selectedLanguage = identifiedLanguages[ietf]; selectedLanguage = identifiedLanguages[ietf];
LOG.Info("Selecteded language " + ietf + " by near match for: " + wantedIETF); LOG.Info("Selecteded language " + ietf + " by near match for: " + wantedIETF);
wantedIETF = ietf; wantedIETF = ietf;
break; break;
} catch (KeyNotFoundException) { } else {
LOG.Warn("Selecteded language " + wantedIETF + " not found."); LOG.Warn("Selecteded language " + wantedIETF + " not found.");
} }
} }
@ -199,9 +208,9 @@ namespace GreenshotPlugin.Core {
} }
if (selectedLanguage == null && !DEFAULT_LANGUAGE.Equals(wantedIETF)) { if (selectedLanguage == null && !DEFAULT_LANGUAGE.Equals(wantedIETF)) {
try { if (identifiedLanguages.ContainsKey(DEFAULT_LANGUAGE)) {
selectedLanguage = identifiedLanguages[DEFAULT_LANGUAGE]; selectedLanguage = identifiedLanguages[DEFAULT_LANGUAGE];
} catch (KeyNotFoundException) { } else {
LOG.Warn("No english language file found!!"); LOG.Warn("No english language file found!!");
} }
} }