diff --git a/FFXIVAPP.Client/App.cs b/FFXIVAPP.Client/App.cs index 4059c7f8..d97ec94e 100644 --- a/FFXIVAPP.Client/App.cs +++ b/FFXIVAPP.Client/App.cs @@ -33,12 +33,10 @@ using System.ComponentModel; using System.Configuration; using System.Diagnostics; -using System.Globalization; using System.IO; using System.Linq; using System.Net.NetworkInformation; using System.Windows; -using System.Windows.Documents; using System.Windows.Threading; using System.Xml; using System.Xml.Linq; @@ -162,12 +160,12 @@ private static void ConfigureNLog() if (hasLocal) { stringReader = new StringReader(XElement.Load(fileName) - .ToString()); + .ToString()); } else { stringReader = new StringReader(XElement.Load(resource.Stream) - .ToString()); + .ToString()); } using (var xmlReader = XmlReader.Create(stringReader)) { @@ -213,25 +211,14 @@ private static void SettingsPropertyChanged(object sender, PropertyChangedEventA break; case "GameLanguage": Constants.GameLanguage = Settings.Default.GameLanguage; - var lang = Settings.Default.GameLanguage.ToLower(); - var cultureInfo = new CultureInfo("en"); - switch (lang) + break; + case "UILanguage": + if (AppViewModel.Instance.UILanguages.Any(ui => ui.Language == Settings.Default.UILanguage)) { - case "french": - cultureInfo = new CultureInfo("fr"); - break; - case "japanese": - cultureInfo = new CultureInfo("ja"); - break; - case "german": - cultureInfo = new CultureInfo("de"); - break; - case "chinese": - cultureInfo = new CultureInfo("zh"); - break; + var uiLanguage = AppViewModel.Instance.UILanguages.First(ui => ui.Language == Settings.Default.UILanguage); + Constants.CultureInfo = Settings.Default.Culture = uiLanguage.CultureInfo; + LocaleHelper.Update(Settings.Default.Culture); } - Constants.CultureInfo = Settings.Default.Culture = cultureInfo; - LocaleHelper.Update(Settings.Default.Culture); break; case "ServerName": Constants.ServerName = Settings.Default.ServerName; diff --git a/FFXIVAPP.Client/AppBootstrapper.cs b/FFXIVAPP.Client/AppBootstrapper.cs index 261da385..fb909fb4 100644 --- a/FFXIVAPP.Client/AppBootstrapper.cs +++ b/FFXIVAPP.Client/AppBootstrapper.cs @@ -31,8 +31,11 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.Runtime.CompilerServices; using System.Timers; +using FFXIVAPP.Client.Models; +using FFXIVAPP.Client.Properties; using FFXIVAPP.Client.Views; using FFXIVAPP.Common.Utilities; using NLog; @@ -107,6 +110,46 @@ private AppBootstrapper() AppViewModel.Instance.SettingsPath = Common.Constants.SettingsPath; AppViewModel.Instance.PluginsSettingsPath = Common.Constants.PluginsSettingsPath; + #region Culture BootStrapping + + AppViewModel.Instance.UILanguages.Add(new UILanguage + { + Language = "English", + ImageURI = "/FFXIVAPP.Client;component/Resources/Media/Icons/en.png", + Title = "English", + CultureInfo = new CultureInfo("en") + }); + AppViewModel.Instance.UILanguages.Add(new UILanguage + { + Language = "Japanese", + ImageURI = "/FFXIVAPP.Client;component/Resources/Media/Icons/ja.png", + Title = "日本語", + CultureInfo = new CultureInfo("ja") + }); + AppViewModel.Instance.UILanguages.Add(new UILanguage + { + Language = "French", + ImageURI = "/FFXIVAPP.Client;component/Resources/Media/Icons/fr.png", + Title = "Français", + CultureInfo = new CultureInfo("fr") + }); + AppViewModel.Instance.UILanguages.Add(new UILanguage + { + Language = "German", + ImageURI = "/FFXIVAPP.Client;component/Resources/Media/Icons/de.png", + Title = "Deutsch", + CultureInfo = new CultureInfo("de") + }); + AppViewModel.Instance.UILanguages.Add(new UILanguage + { + Language = "Chinese", + ImageURI = "/FFXIVAPP.Client;component/Resources/Media/Icons/cn.png", + Title = "中國", + CultureInfo = new CultureInfo("zh") + }); + + #endregion + #region Initial BootStrapping Initializer.SetupCurrentUICulture(); diff --git a/FFXIVAPP.Client/AppViewModel.cs b/FFXIVAPP.Client/AppViewModel.cs index ffe9f572..61f90040 100644 --- a/FFXIVAPP.Client/AppViewModel.cs +++ b/FFXIVAPP.Client/AppViewModel.cs @@ -40,6 +40,7 @@ using System.Windows.Forms; using System.Windows.Threading; using FFXIVAPP.Client.Memory; +using FFXIVAPP.Client.Models; using FFXIVAPP.Client.Properties; using FFXIVAPP.Common.Core.Memory; using FFXIVAPP.Common.Helpers; @@ -76,6 +77,22 @@ internal sealed class AppViewModel : INotifyPropertyChanged private Style _tabControlCollapsedHeader; private List _updateNotes; + #region UILanguages + + private ObservableCollection _uiLanguages; + + public ObservableCollection UILanguages + { + get { return _uiLanguages ?? (_uiLanguages = new ObservableCollection()); } + set + { + _uiLanguages = value; + RaisePropertyChanged(); + } + } + + #endregion + public static AppViewModel Instance { get { return _instance ?? (_instance = new AppViewModel()); } diff --git a/FFXIVAPP.Client/FFXIVAPP.Client.csproj b/FFXIVAPP.Client/FFXIVAPP.Client.csproj index cc02cbb5..8faee986 100644 --- a/FFXIVAPP.Client/FFXIVAPP.Client.csproj +++ b/FFXIVAPP.Client/FFXIVAPP.Client.csproj @@ -178,6 +178,7 @@ + diff --git a/FFXIVAPP.Client/Localization/Chinese.cs b/FFXIVAPP.Client/Localization/Chinese.cs index 9f4ea91e..56dffa40 100644 --- a/FFXIVAPP.Client/Localization/Chinese.cs +++ b/FFXIVAPP.Client/Localization/Chinese.cs @@ -127,6 +127,9 @@ public static ResourceDictionary Context() Dictionary.Add("app_pluginUpdateMessageText", "看來某些插件有更新。為了確保兼容性, 請在 \"更新\" 選項內更新插件."); Dictionary.Add("app_CurrentVersionHeader", "现在"); Dictionary.Add("app_LatestVersionHeader", "最新"); + Dictionary.Add("app_UILanguageChangeWarningGeneral", "Do you want to change the GameLanguage setting as well to match this applications UILanguage? If you cancel you will manually have to change GameLanguage in Settings later."); + Dictionary.Add("app_UILanguageChangeWarningChinese", " When changing to or from Chinese an application restart is also required."); + Dictionary.Add("app_UILanguageChangeWarningNoGameLanguage", "The selected UILanguage does not have a supported GameLanguage. Please choose your game language in Settings."); return Dictionary; } } diff --git a/FFXIVAPP.Client/Localization/English.cs b/FFXIVAPP.Client/Localization/English.cs index 6e13ef5a..1fba305b 100644 --- a/FFXIVAPP.Client/Localization/English.cs +++ b/FFXIVAPP.Client/Localization/English.cs @@ -127,6 +127,9 @@ public static ResourceDictionary Context() Dictionary.Add("app_pluginUpdateMessageText", "It appears some plugins have updates available. To ensure compatibility please update at your earliest convenience via the \"Update\" tab."); Dictionary.Add("app_CurrentVersionHeader", "Current"); Dictionary.Add("app_LatestVersionHeader", "Latest"); + Dictionary.Add("app_UILanguageChangeWarningGeneral", "Do you want to change the GameLanguage setting as well to match this applications UILanguage? If you cancel you will manually have to change GameLanguage in Settings later."); + Dictionary.Add("app_UILanguageChangeWarningChinese", " When changing to or from Chinese an application restart is also required."); + Dictionary.Add("app_UILanguageChangeWarningNoGameLanguage", "The selected UILanguage does not have a supported GameLanguage. Please choose your game language in Settings."); return Dictionary; } } diff --git a/FFXIVAPP.Client/Localization/French.cs b/FFXIVAPP.Client/Localization/French.cs index f0b7b0af..552bb004 100644 --- a/FFXIVAPP.Client/Localization/French.cs +++ b/FFXIVAPP.Client/Localization/French.cs @@ -127,6 +127,9 @@ public static ResourceDictionary Context() Dictionary.Add("app_pluginUpdateMessageText", "Il semble que certains plugins aient des mises à jour disponibles. Pour vous assurer de leur compatibilité, veuillez les mettre à jour à votre meilleure convenance via le tab \"Mises à jour\""); Dictionary.Add("app_CurrentVersionHeader", "Actuelle"); Dictionary.Add("app_LatestVersionHeader", "Dernière"); + Dictionary.Add("app_UILanguageChangeWarningGeneral", "Do you want to change the GameLanguage setting as well to match this applications UILanguage? If you cancel you will manually have to change GameLanguage in Settings later."); + Dictionary.Add("app_UILanguageChangeWarningChinese", " When changing to or from Chinese an application restart is also required."); + Dictionary.Add("app_UILanguageChangeWarningNoGameLanguage", "The selected UILanguage does not have a supported GameLanguage. Please choose your game language in Settings."); return Dictionary; } } diff --git a/FFXIVAPP.Client/Localization/German.cs b/FFXIVAPP.Client/Localization/German.cs index ed7dc7c8..6de04784 100644 --- a/FFXIVAPP.Client/Localization/German.cs +++ b/FFXIVAPP.Client/Localization/German.cs @@ -127,6 +127,9 @@ public static ResourceDictionary Context() Dictionary.Add("app_pluginUpdateMessageText", "It appears some plugins have updates available. To ensure compatibility please update at your earliest convenience via the \"Update\" tab."); Dictionary.Add("app_CurrentVersionHeader", "Current"); Dictionary.Add("app_LatestVersionHeader", "Latest"); + Dictionary.Add("app_UILanguageChangeWarningGeneral", "Do you want to change the GameLanguage setting as well to match this applications UILanguage? If you cancel you will manually have to change GameLanguage in Settings later."); + Dictionary.Add("app_UILanguageChangeWarningChinese", " When changing to or from Chinese an application restart is also required."); + Dictionary.Add("app_UILanguageChangeWarningNoGameLanguage", "The selected UILanguage does not have a supported GameLanguage. Please choose your game language in Settings."); return Dictionary; } } diff --git a/FFXIVAPP.Client/Localization/Japanese.cs b/FFXIVAPP.Client/Localization/Japanese.cs index 3955f2f9..e722e9cb 100644 --- a/FFXIVAPP.Client/Localization/Japanese.cs +++ b/FFXIVAPP.Client/Localization/Japanese.cs @@ -127,6 +127,9 @@ public static ResourceDictionary Context() Dictionary.Add("app_pluginUpdateMessageText", "いくつかのプラグインに利用可能な最新の更新があります。全体の動作を保証するために\"更新する\"タブから更新を行って下さい。"); Dictionary.Add("app_CurrentVersionHeader", "現在"); Dictionary.Add("app_LatestVersionHeader", "最新"); + Dictionary.Add("app_UILanguageChangeWarningGeneral", "Do you want to change the GameLanguage setting as well to match this applications UILanguage? If you cancel you will manually have to change GameLanguage in Settings later."); + Dictionary.Add("app_UILanguageChangeWarningChinese", " When changing to or from Chinese an application restart is also required."); + Dictionary.Add("app_UILanguageChangeWarningNoGameLanguage", "The selected UILanguage does not have a supported GameLanguage. Please choose your game language in Settings."); return Dictionary; } } diff --git a/FFXIVAPP.Client/Models/UILanguage.cs b/FFXIVAPP.Client/Models/UILanguage.cs new file mode 100644 index 00000000..278c7f1b --- /dev/null +++ b/FFXIVAPP.Client/Models/UILanguage.cs @@ -0,0 +1,41 @@ +// FFXIVAPP.Client +// UILanguage.cs +// +// Copyright © 2007 - 2015 Ryan Wilson - All Rights Reserved +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of SyndicatedLife nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +using System.Globalization; + +namespace FFXIVAPP.Client.Models +{ + public class UILanguage + { + public string Language { get; set; } + public string ImageURI { get; set; } + public string Title { get; set; } + public CultureInfo CultureInfo { get; set; } + } +} diff --git a/FFXIVAPP.Client/Properties/Settings.Designer.cs b/FFXIVAPP.Client/Properties/Settings.Designer.cs index 08c8e1fb..253a1e35 100644 --- a/FFXIVAPP.Client/Properties/Settings.Designer.cs +++ b/FFXIVAPP.Client/Properties/Settings.Designer.cs @@ -557,5 +557,17 @@ internal sealed partial class Settings : global::System.Configuration.Applicatio this["EnableNetworkReading"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string UILanguage { + get { + return ((string)(this["UILanguage"])); + } + set { + this["UILanguage"] = value; + } + } } } diff --git a/FFXIVAPP.Client/Properties/Settings.settings b/FFXIVAPP.Client/Properties/Settings.settings index 89833d8c..67bbe2ae 100644 --- a/FFXIVAPP.Client/Properties/Settings.settings +++ b/FFXIVAPP.Client/Properties/Settings.settings @@ -259,5 +259,8 @@ False + + + \ No newline at end of file diff --git a/FFXIVAPP.Client/ShellView.xaml b/FFXIVAPP.Client/ShellView.xaml index f085a933..375ae5f2 100644 --- a/FFXIVAPP.Client/ShellView.xaml +++ b/FFXIVAPP.Client/ShellView.xaml @@ -63,46 +63,28 @@ - - - - - + + + + + + + + + +