Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions PasteIntoFile/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<setting name="autoSaveMayOpenNewExplorer" serializeAs="String">
<value>False</value>
</setting>
<setting name="language" serializeAs="String">
<value />
</setting>
</PasteIntoFile.Properties.Settings>
</userSettings>
</configuration>
14 changes: 14 additions & 0 deletions PasteIntoFile/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down
18 changes: 18 additions & 0 deletions PasteIntoFile/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions PasteIntoFile/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,10 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Unterordner-Vorlage</value>
</data>
<data name="str_language" xml:space="preserve">
<value>Sprache</value>
</data>
<data name="str_system_language" xml:space="preserve">
<value>Systemsprache</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.es-ES.resx
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Plantilla de subcarpeta</value>
</data>
<data name="str_language" xml:space="preserve">
<value>Idioma</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_append" xml:space="preserve">
<value>Ajouter</value>
</data>
<data name="str_language" xml:space="preserve">
<value>Langue</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.it.resx
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Modello sottocartella</value>
</data>
<data name="str_language" xml:space="preserve">
<value>Lingua</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.ja-JP.resx
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>サブフォルダーテンプレート</value>
</data>
<data name="str_language" xml:space="preserve">
<value>言語</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Modelo de subpasta</value>
</data>
<data name="language_name" xml:space="preserve">
<value>🇧🇷 (PT-BR)</value>
</data>
</root>
3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Resources.pt-PT.resx
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,7 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Modelo de subpasta</value>
</data>
<data name="language_name" xml:space="preserve">
<value>(PT-PT)</value>
</data>
</root>
6 changes: 6 additions & 0 deletions PasteIntoFile/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,10 @@ Allows to keep application window always on top (in foreground of other windows)
<data name="str_subfolder_template" xml:space="preserve">
<value>Subfolder template</value>
</data>
<data name="str_language" xml:space="preserve">
<value>Language</value>
</data>
<data name="str_system_language" xml:space="preserve">
<value>System language</value>
</data>
</root>
12 changes: 12 additions & 0 deletions PasteIntoFile/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PasteIntoFile/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<Setting Name="autoSaveMayOpenNewExplorer" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="language" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

6 changes: 6 additions & 0 deletions PasteIntoFile/Wizard.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions PasteIntoFile/Wizard.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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

Expand All @@ -26,6 +35,9 @@ public Wizard() {
patchingCheckBox.Checked = Settings.Default.trayPatchingEnabled;
patchingCheckBox.Enabled = autostartCheckBox.Checked;

// Menu
UpdateLanguageMenu();

// Version info
var versionstr = ProductVersion;
#if PORTABLE
Expand All @@ -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()) {
Expand Down