Skip to content

Commit

Permalink
Language selection from combo-box in General tab
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTheGr8 committed Oct 7, 2013
1 parent 8884ceb commit 9bf5456
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 1,653 deletions.
20 changes: 20 additions & 0 deletions FTPboxLib/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public static partial class Common

public static Translations Languages = new Translations(); //Used to grab the translations from the translations.xml file

// All available languages and their shortcodes
public static readonly Dictionary<string, string> LanguageList = new Dictionary<string, string> {
{ "en", "English" }, { "es", "Spanish" }, { "de", "German" }, { "fr", "French" }, { "nl", "Dutch" }, { "el", "Greek" }, { "it", "Italian" }, { "tr", "Turkish" }, { "pt-BR", "Brazilian Portuguese" }, { "fo", "Faroese" }, { "sv", "Swedish" }, { "sq", "Albanian" }, { "ro", "Romanian" }, { "ko", "Korean" }, { "ru", "Russian" }, { "ja", "Japanese" }, { "no", "Norwegian" }, { "hu", "Hungarian" }, { "vi", "Vietnamese" }, { "zh_HANS", "Chinese, Simplified" }, { "zh_HANT", "Chinese, Traditional" }, { "lt", "Lithuanian" }, { "da", "Dansk" }, { "pl", "Polish" }, { "hr", "Croatian" }, { "sk", "Slovak" }, { "pt", "Portuguese" }, { "gl", "Galego" }, { "th", "Thai" }, { "sl", "Slovenian" }, { "cs", "Czech" }, { "he", "Hebrew" }, { "sr", "Serbian" }, { "src", "Serbian, Cyrillic" }
}.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);


#endregion

#region Methods
Expand Down Expand Up @@ -209,6 +215,20 @@ public static string DebugLogPath
get { return Path.Combine(AppdataFolder, "Debug.html"); }
}

public static string[] FormattedLanguageList
{
get { return LanguageList.ToList().ConvertAll(x => string.Format("{0} ({1})", x.Value, x.Key)).ToArray(); }
}

public static int SelectedLanguageIndex
{
get
{
return string.IsNullOrWhiteSpace(Settings.General.Language)
? LanguageList.Keys.ToList().IndexOf("en") : LanguageList.Keys.ToList().IndexOf(Settings.General.Language);
}
}

#endregion
}
}
Binary file modified Windows/FTPbox.suo
Binary file not shown.
Binary file modified Windows/FTPbox.v11.suo
Binary file not shown.
15 changes: 5 additions & 10 deletions Windows/FTPbox/Forms/Setup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
Expand All @@ -21,9 +20,6 @@ public partial class Setup : Form
private bool _checkingNodes = false;
public static bool JustPassword = false;

private readonly Dictionary<string, string> langList = new Dictionary<string, string>
{ {"en", "English" }, { "es", "Spanish" }, { "de", "German" }, { "fr", "French" }, { "nl", "Dutch" }, { "el", "Greek" }, { "it", "Italian" }, { "tr", "Turkish" }, { "pt-BR", "Brazilian Portuguese" }, { "fo", "Faroese" }, { "sv", "Swedish" }, { "sq", "Albanian" }, { "ro", "Romanian" }, { "ko", "Korean" }, { "ru", "Russian" }, { "ja", "Japanese" }, { "no", "Norwegian" }, { "hu", "Hungarian" }, { "vi", "Vietnamese" }, { "zh_HANS", "Simplified Chinese" }, { "zh_HANT", "Traditional Chinese" }, { "lt", "Lithuanian" }, { "da", "Dansk" }, { "pl", "Polish" }, { "hr", "Croatian" }, { "sk", "Slovak" }, { "pt", "Portuguese" }, { "gl", "Galego" }, { "th", "Thai" }, { "sl", "Slovenian" }, { "cs", "Czech" }, { "he", "Hebrew" }, { "sr", "Serbian" } };

public Setup()
{
InitializeComponent();
Expand Down Expand Up @@ -153,11 +149,10 @@ private void SwitchTab(AccountSetupTab tab)
/// </summary>
private void PopulateLanguages()
{
cLanguages.Items.Clear();
var formatted = langList.ToList().ConvertAll(x => string.Format("{0} ({1})", x.Value, x.Key)).ToArray();
cLanguages.Items.AddRange(formatted);
cLanguages.Items.Clear();
cLanguages.Items.AddRange(Common.FormattedLanguageList);
// Default to English
cLanguages.SelectedIndex = 0;
cLanguages.SelectedIndex = Common.SelectedLanguageIndex;
}

/// <summary>
Expand All @@ -168,8 +163,8 @@ private void CheckCurrentLanguage()
{
var locallangtwoletter = System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;

if (langList.ContainsKey(locallangtwoletter))
cLanguages.SelectedIndex = langList.Keys.ToList().IndexOf(locallangtwoletter);
if (Common.LanguageList.ContainsKey(locallangtwoletter))
cLanguages.SelectedIndex = Common.LanguageList.Keys.ToList().IndexOf(locallangtwoletter);
}

/// <summary>
Expand Down
147 changes: 22 additions & 125 deletions Windows/FTPbox/Forms/Translate.Designer.cs

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

Loading

0 comments on commit 9bf5456

Please sign in to comment.