diff --git a/PasteIntoFile/App.config b/PasteIntoFile/App.config index 320cb47..1678a39 100644 --- a/PasteIntoFile/App.config +++ b/PasteIntoFile/App.config @@ -58,6 +58,9 @@ False + + + \ No newline at end of file diff --git a/PasteIntoFile/Main.cs b/PasteIntoFile/Main.cs index 098f00d..943e613 100644 --- a/PasteIntoFile/Main.cs +++ b/PasteIntoFile/Main.cs @@ -90,6 +90,9 @@ class ArgsConfig : ArgsCommon { [Option("disable-patching", HelpText = "Disables clipboard patching", SetName = "patching")] public bool UnregisterPatching { get; set; } + [Option("language", HelpText = "ISO 639-1 language code for UI Localization ('auto' for system language)", SetName = "language")] + public string Language { get; set; } + } [Verb("wizard", HelpText = "Open the first-launch wizard")] @@ -119,6 +122,13 @@ static int Main(string[] args) { PortableSettingsProvider.ApplyProvider(Settings.Default); #endif + // Localization + try { + Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Settings.Default.language); + } catch (CultureNotFoundException e) { + Console.WriteLine(e.Message); + } + Settings.Default.continuousMode = false; // always start in normal mode Settings.Default.Save(); @@ -397,6 +407,10 @@ static int RunConfig(ArgsConfig args) { Settings.Default.clrClipboard = (bool)args.ClearClipboard; if (args.Autosave != null) Wizard.SetAutosaveMode((bool)args.Autosave); + if (args.Language != null) { + Settings.Default.language = args.Language.ToLowerInvariant() == "auto" ? "" : args.Language; + Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Settings.Default.language); + } if (args.RegisterContextMenu) foreach (var entry in RegistryUtil.AllContextMenu) { entry.Register(); diff --git a/PasteIntoFile/Properties/Resources.Designer.cs b/PasteIntoFile/Properties/Resources.Designer.cs index 80070e2..7a40177 100644 --- a/PasteIntoFile/Properties/Resources.Designer.cs +++ b/PasteIntoFile/Properties/Resources.Designer.cs @@ -335,6 +335,15 @@ internal static string str_invalid_character { } } + /// + /// Looks up a localized string similar to Language. + /// + internal static string str_language { + get { + return ResourceManager.GetString("str_language", resourceCulture); + } + } + /// /// Looks up a localized string similar to Folder. /// @@ -569,6 +578,15 @@ internal static string str_subfolder_template { } } + /// + /// Looks up a localized string similar to System language. + /// + internal static string str_system_language { + get { + return ResourceManager.GetString("str_system_language", resourceCulture); + } + } + /// /// Looks up a localized string similar to The filename template is used to format the filename. . /// diff --git a/PasteIntoFile/Properties/Resources.de.resx b/PasteIntoFile/Properties/Resources.de.resx index c8a1c32..67c2208 100644 --- a/PasteIntoFile/Properties/Resources.de.resx +++ b/PasteIntoFile/Properties/Resources.de.resx @@ -309,4 +309,10 @@ Allows to keep application window always on top (in foreground of other windows) Unterordner-Vorlage + + Sprache + + + Systemsprache + diff --git a/PasteIntoFile/Properties/Resources.es-ES.resx b/PasteIntoFile/Properties/Resources.es-ES.resx index de42bb3..5f1da0d 100644 --- a/PasteIntoFile/Properties/Resources.es-ES.resx +++ b/PasteIntoFile/Properties/Resources.es-ES.resx @@ -309,4 +309,7 @@ Allows to keep application window always on top (in foreground of other windows) Plantilla de subcarpeta + + Idioma + diff --git a/PasteIntoFile/Properties/Resources.fr.resx b/PasteIntoFile/Properties/Resources.fr.resx index dedb362..e900af6 100644 --- a/PasteIntoFile/Properties/Resources.fr.resx +++ b/PasteIntoFile/Properties/Resources.fr.resx @@ -179,4 +179,7 @@ Allows to keep application window always on top (in foreground of other windows) Ajouter + + Langue + diff --git a/PasteIntoFile/Properties/Resources.it.resx b/PasteIntoFile/Properties/Resources.it.resx index e3adbb4..225b5c9 100644 --- a/PasteIntoFile/Properties/Resources.it.resx +++ b/PasteIntoFile/Properties/Resources.it.resx @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows) Modello sottocartella + + Lingua + diff --git a/PasteIntoFile/Properties/Resources.ja-JP.resx b/PasteIntoFile/Properties/Resources.ja-JP.resx index d4b0830..f897b30 100644 --- a/PasteIntoFile/Properties/Resources.ja-JP.resx +++ b/PasteIntoFile/Properties/Resources.ja-JP.resx @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows) サブフォルダーテンプレート + + 言語 + diff --git a/PasteIntoFile/Properties/Resources.pt-BR.resx b/PasteIntoFile/Properties/Resources.pt-BR.resx index a566c80..d7b24ce 100644 --- a/PasteIntoFile/Properties/Resources.pt-BR.resx +++ b/PasteIntoFile/Properties/Resources.pt-BR.resx @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows) Modelo de subpasta + + 🇧🇷 (PT-BR) + diff --git a/PasteIntoFile/Properties/Resources.pt-PT.resx b/PasteIntoFile/Properties/Resources.pt-PT.resx index c56d4b6..ef53cb3 100644 --- a/PasteIntoFile/Properties/Resources.pt-PT.resx +++ b/PasteIntoFile/Properties/Resources.pt-PT.resx @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows) Modelo de subpasta + + (PT-PT) + diff --git a/PasteIntoFile/Properties/Resources.resx b/PasteIntoFile/Properties/Resources.resx index 06b73d7..1e608e5 100644 --- a/PasteIntoFile/Properties/Resources.resx +++ b/PasteIntoFile/Properties/Resources.resx @@ -321,4 +321,10 @@ Allows to keep application window always on top (in foreground of other windows) Subfolder template + + Language + + + System language + diff --git a/PasteIntoFile/Properties/Settings.Designer.cs b/PasteIntoFile/Properties/Settings.Designer.cs index bfba1e8..b47b5a1 100644 --- a/PasteIntoFile/Properties/Settings.Designer.cs +++ b/PasteIntoFile/Properties/Settings.Designer.cs @@ -201,5 +201,17 @@ public bool autoSaveMayOpenNewExplorer { this["autoSaveMayOpenNewExplorer"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string language { + get { + return ((string)(this["language"])); + } + set { + this["language"] = value; + } + } } } diff --git a/PasteIntoFile/Properties/Settings.settings b/PasteIntoFile/Properties/Settings.settings index 2e1ae91..fcb9d91 100644 --- a/PasteIntoFile/Properties/Settings.settings +++ b/PasteIntoFile/Properties/Settings.settings @@ -47,6 +47,9 @@ False + + + diff --git a/PasteIntoFile/Wizard.Designer.cs b/PasteIntoFile/Wizard.Designer.cs index 98b0270..cae4850 100644 --- a/PasteIntoFile/Wizard.Designer.cs +++ b/PasteIntoFile/Wizard.Designer.cs @@ -50,6 +50,8 @@ private void InitializeComponent() { // // tableLayoutPanel1 // + this.tableLayoutPanel1.AutoScroll = true; + this.tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink; this.tableLayoutPanel1.ColumnCount = 1; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.Controls.Add(this.title, 0, 0); @@ -308,6 +310,9 @@ private void InitializeComponent() { this.settingsMenuClearClipboard.Text = Resources.str_clear_clipboard; this.settingsMenuClearClipboard.ToolTipText = Resources.str_clear_clipboard_tooltip; this.settingsMenu.Items.Add(this.settingsMenuClearClipboard); + this.settingsMenuLanguage = new ToolStripMenuItem(); + this.settingsMenuLanguage.Text = Resources.str_language + " 🌐"; + this.settingsMenu.Items.Add(this.settingsMenuLanguage); // // settings button // @@ -345,6 +350,7 @@ private void InitializeComponent() { private System.Windows.Forms.ContextMenuStrip settingsMenu; private System.Windows.Forms.ToolStripMenuItem settingsMenuUpdateChecks; private System.Windows.Forms.ToolStripMenuItem settingsMenuClearClipboard; + private System.Windows.Forms.ToolStripMenuItem settingsMenuLanguage; private System.Windows.Forms.LinkLabel version; private System.Windows.Forms.Button finish; private System.Windows.Forms.CheckBox contextEntryCheckBoxPaste; diff --git a/PasteIntoFile/Wizard.cs b/PasteIntoFile/Wizard.cs index 1609c66..5b25ebf 100644 --- a/PasteIntoFile/Wizard.cs +++ b/PasteIntoFile/Wizard.cs @@ -1,6 +1,10 @@ using System; using System.Diagnostics; using System.Drawing; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using PasteIntoFile.Properties; @@ -10,6 +14,11 @@ namespace PasteIntoFile { public sealed partial class Wizard : MasterForm { public Wizard() { + ReloadUi(); + } + + private void ReloadUi() { + Controls.Clear(); InitializeComponent(); Settings.Default.Reload(); // load modifications made from other instance @@ -26,6 +35,9 @@ public Wizard() { patchingCheckBox.Checked = Settings.Default.trayPatchingEnabled; patchingCheckBox.Enabled = autostartCheckBox.Checked; + // Menu + UpdateLanguageMenu(); + // Version info var versionstr = ProductVersion; #if PORTABLE @@ -44,6 +56,31 @@ public Wizard() { MakeDarkMode(); } } + private void UpdateLanguageMenu() { + var dir = Path.GetDirectoryName(Application.ExecutablePath); + var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures) + .Where(culture => culture.Name == "en" || Directory.Exists(Path.Combine(dir, culture.Name))); + + settingsMenuLanguage.DropDownItems.Clear(); + foreach (var culture in cultures) { + var flag = string.Concat(culture.TwoLetterISOLanguageName.ToUpperInvariant().Select(x => char.ConvertFromUtf32(x + 0x1F1A5))); // + "\ufe0f" + var description = Equals(culture, CultureInfo.InvariantCulture) ? Resources.str_system_language + @" 💻️" + : culture.DisplayName + @" – " + culture.NativeName + @" [" + culture.Name + @"]"; + + var item = new ToolStripMenuItem(description, null, (sender, args) => { + Settings.Default.language = culture.Name; + Settings.Default.Save(); + Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Settings.Default.language); + ReloadUi(); + Height += 100; + }); + + item.Checked = Settings.Default.language == culture.Name; + settingsMenuLanguage.DropDownItems.Add(item); + + } + + } async Task CheckForUpdates() { if (await Program.CheckForUpdates()) {