mattercontrol/ConfigurationPage/LanguageSelector.cs

62 lines
1.4 KiB
C#
Raw Normal View History

2016-06-03 18:11:51 -07:00
using MatterHackers.Agg.UI;
using MatterHackers.VectorMath;
2014-03-20 13:57:17 -07:00
using System.Collections.Generic;
namespace MatterHackers.MatterControl
{
2016-06-03 18:11:51 -07:00
public class LanguageSelector : DropDownList
2015-04-08 15:20:10 -07:00
{
private Dictionary<string, string> languageDict;
public LanguageSelector(ThemeConfig theme)
: base("Default", theme.Colors.PrimaryTextColor)
2015-04-08 15:20:10 -07:00
{
this.MinimumSize = new Vector2(this.LocalBounds.Width, this.LocalBounds.Height);
this.BorderColor = theme.GetBorderColor(75);
2015-04-08 15:20:10 -07:00
CreateLanguageDict();
foreach (KeyValuePair<string, string> entry in languageDict)
{
AddItem(entry.Key, entry.Value);
}
string languageCode = UserSettings.Instance.get("Language");
2015-04-08 15:20:10 -07:00
foreach (KeyValuePair<string, string> entry in languageDict)
{
if (languageCode == entry.Value)
{
SelectedLabel = entry.Key;
break;
}
}
}
private void CreateLanguageDict()
{
languageDict = new Dictionary<string, string>
{
["Default"] = "EN",
["English"] = "EN",
["Čeština"] = "CS",
["Dansk"] = "DA",
2018-03-19 14:07:01 -07:00
["Deutsch"] = "DE",
["Español"] = "ES",
2018-03-19 14:07:01 -07:00
["ελληνικά"] = "EL",
["Français"] = "FR",
["Italiano"] = "IT",
["Norsk"] = "NO",
["Polski"] = "PL",
2018-03-19 14:07:01 -07:00
["Português"] = "CR",
["Русский"] = "RU",
["Română"] = "RO",
["Türkçe"] = "TR",
["Vlaams"] = "NL",
};
#if DEBUG
languageDict["L10N"] = "L10N";
#endif
2015-04-08 15:20:10 -07:00
}
}
}