From e9fad994164ef83f0e70c2f712a89186790de585 Mon Sep 17 00:00:00 2001 From: Pavel Petroshenko Date: Sun, 18 May 2008 19:36:55 +0000 Subject: [PATCH] - OK/cancel/apply logics for localization option; - Localized buttons and window title; git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@82 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/webimtray/WebIMTray/Options.cs | 8 ++++ .../options/OptionsDialog.Designer.cs | 4 -- .../WebIMTray/options/OptionsDialog.cs | 9 ++++ .../WebIMTray/options/OptionsGeneralPanel.cs | 42 ++++++++++++------- src/webimtray/WebIMTray/webImTray.en-US.resx | 12 ++++++ src/webimtray/WebIMTray/webImTray.ru-RU.resx | 12 ++++++ 6 files changed, 69 insertions(+), 18 deletions(-) diff --git a/src/webimtray/WebIMTray/Options.cs b/src/webimtray/WebIMTray/Options.cs index 45ce1805..14621492 100644 --- a/src/webimtray/WebIMTray/Options.cs +++ b/src/webimtray/WebIMTray/Options.cs @@ -104,5 +104,13 @@ namespace webImTray { if (args.Length == 1 && args[0].Equals("/show")) forceShowWindow = true; } + + public static bool RussianLocale { + get { + return Application.UserAppDataRegistry.GetValue("isrussianlocale", "false").ToString().ToLower().Equals("true"); + } set { + Application.UserAppDataRegistry.SetValue("isrussianlocale", value.ToString()); + } + } } } diff --git a/src/webimtray/WebIMTray/options/OptionsDialog.Designer.cs b/src/webimtray/WebIMTray/options/OptionsDialog.Designer.cs index 6393e27d..82f9babd 100644 --- a/src/webimtray/WebIMTray/options/OptionsDialog.Designer.cs +++ b/src/webimtray/WebIMTray/options/OptionsDialog.Designer.cs @@ -131,9 +131,5 @@ namespace webImTray { private System.Windows.Forms.Button apply; private System.Windows.Forms.Panel container; private System.Windows.Forms.LinkLabel linkLabel1; - - - - } } \ No newline at end of file diff --git a/src/webimtray/WebIMTray/options/OptionsDialog.cs b/src/webimtray/WebIMTray/options/OptionsDialog.cs index d2577f17..25a4a829 100644 --- a/src/webimtray/WebIMTray/options/OptionsDialog.cs +++ b/src/webimtray/WebIMTray/options/OptionsDialog.cs @@ -24,8 +24,13 @@ namespace webImTray { public static CultureInfo englishCulture = new CultureInfo("en-US"); public static CultureInfo russianCulture = new CultureInfo("ru-RU"); + // FIXME: we have only one OptionsDialog instance + // thus it's safe to keep it in a static variable. + private static OptionsDialog currentInstance = null; + public OptionsDialog() { InitializeComponent(); + currentInstance = this; } private void changePanel(OptionsPanel panel) { @@ -102,6 +107,10 @@ namespace webImTray { for (int i = 0; i < 4; i++) { ((OptionsPanel)panels[i]).updateUI(resourceManager); } + currentInstance.ok.Text = resourceManager.GetString("ok"); + currentInstance.cancel.Text = resourceManager.GetString("cancel"); + currentInstance.apply.Text = resourceManager.GetString("apply"); + currentInstance.Text = resourceManager.GetString("optionsTitle"); } } } \ No newline at end of file diff --git a/src/webimtray/WebIMTray/options/OptionsGeneralPanel.cs b/src/webimtray/WebIMTray/options/OptionsGeneralPanel.cs index 4908410e..e92d9d7e 100644 --- a/src/webimtray/WebIMTray/options/OptionsGeneralPanel.cs +++ b/src/webimtray/WebIMTray/options/OptionsGeneralPanel.cs @@ -7,6 +7,7 @@ using System.Text; using System.Windows.Forms; using System.Resources; using System.Threading; +using System.Globalization; namespace webImTray { public partial class OptionsGeneralPanel : UserControl, OptionsPanel { @@ -27,6 +28,18 @@ namespace webImTray { Options.ShowInTaskBar = showInTaskBar.Checked; Options.AutoStart = autoStart.Checked; Options.HideAfterStart = hideWhenStarted.Checked; + + // Save locale + Options.RussianLocale = radioRussian.Checked; + + // Apply locale + if (radioEnglish.Checked) { + Thread.CurrentThread.CurrentUICulture = OptionsDialog.englishCulture; + } else if (radioRussian.Checked) { + Thread.CurrentThread.CurrentUICulture = OptionsDialog.russianCulture; + } + // Update UI according to the current locale + OptionsDialog.updateUI(); modified = false; } } @@ -35,6 +48,17 @@ namespace webImTray { showInTaskBar.Checked = Options.ShowInTaskBar; autoStart.Checked = Options.AutoStart; hideWhenStarted.Checked = Options.HideAfterStart; + + // Restore previously set locale + if (!Options.RussianLocale) { + radioEnglish.Checked = true; + } else { + radioRussian.Checked = true; + } + + // Update UI according to the current locale + OptionsDialog.updateUI(); + modified = false; } @@ -56,23 +80,13 @@ namespace webImTray { } private void radioEnglish_CheckedChanged(object sender, EventArgs e) { - if (radioEnglish.Checked) { - // Set english culture - Thread.CurrentThread.CurrentUICulture = OptionsDialog.englishCulture; - - // Update UI - OptionsDialog.updateUI(); - } + modified = true; + PanelModified.Invoke(); } private void radioRussian_CheckedChanged(object sender, EventArgs e) { - if (radioRussian.Checked) { - // Set russian culture - Thread.CurrentThread.CurrentUICulture = OptionsDialog.russianCulture; - - // Update UI - OptionsDialog.updateUI(); - } + modified = true; + PanelModified.Invoke(); } } } diff --git a/src/webimtray/WebIMTray/webImTray.en-US.resx b/src/webimtray/WebIMTray/webImTray.en-US.resx index d77d6d3a..5eadf1c9 100644 --- a/src/webimtray/WebIMTray/webImTray.en-US.resx +++ b/src/webimtray/WebIMTray/webImTray.en-US.resx @@ -120,6 +120,9 @@ Application + + Apply + Become idle if the screen saver is activated @@ -129,6 +132,9 @@ Start automatically when starting Windows + + Cancel + Connection @@ -156,9 +162,15 @@ Notifications + + OK + Operator preferences + + Web IM Tray Options + Play sound when visitor comes diff --git a/src/webimtray/WebIMTray/webImTray.ru-RU.resx b/src/webimtray/WebIMTray/webImTray.ru-RU.resx index d74fa282..90851743 100644 --- a/src/webimtray/WebIMTray/webImTray.ru-RU.resx +++ b/src/webimtray/WebIMTray/webImTray.ru-RU.resx @@ -120,6 +120,9 @@ Приложение + + Применить + Автоматически отсоединяться, если запущен хранитель экрана @@ -129,6 +132,9 @@ Запускать автоматически при загрузке системы + + Нет + Соединение @@ -156,9 +162,15 @@ Звуковые уведомления + + Да + Настройки оператора + + Настройки Веб Мессенджер "Трей" + Звуковое уведомление о появлении посетителя