From ed9007cab7d46e8fb271cfb5536c1936097dbf6c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 12 Aug 2016 14:01:09 +0200 Subject: Save GUI language as string instead of wxLanguage enum When 5.0-211 updated wxWidgets to 3.1.0, some entries in the wxLanguage enum were moved and added, changing the wxLanguage values. Because we save Dolphin's interface language to disk as a wxLanguage, the language you have set will mean something different depending on whether you have the updated wx version or not. For instance, setting the language to English with the updated version and then using an older version will make Dolphin use Dutch. Because we can't rely on the enum anymore, I'm replacing the "Language" setting with a "LanguageCode" setting that uses standard ISO 639 codes. --- .../Core/DolphinWX/Config/InterfaceConfigPane.cpp | 40 +++++----------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp') diff --git a/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp b/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp index a3934c9b8f..30a3c7aa30 100644 --- a/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp @@ -27,38 +27,14 @@ #include "DolphinWX/X11Utils.h" #endif -static const wxLanguage language_ids[] = { - wxLANGUAGE_DEFAULT, - - wxLANGUAGE_MALAY, - wxLANGUAGE_CATALAN, - wxLANGUAGE_CZECH, - wxLANGUAGE_DANISH, - wxLANGUAGE_GERMAN, - wxLANGUAGE_ENGLISH, - wxLANGUAGE_SPANISH, - wxLANGUAGE_FRENCH, - wxLANGUAGE_CROATIAN, - wxLANGUAGE_ITALIAN, - wxLANGUAGE_HUNGARIAN, - wxLANGUAGE_DUTCH, - wxLANGUAGE_NORWEGIAN_BOKMAL, - wxLANGUAGE_POLISH, - wxLANGUAGE_PORTUGUESE, - wxLANGUAGE_PORTUGUESE_BRAZILIAN, - wxLANGUAGE_ROMANIAN, - wxLANGUAGE_SERBIAN, - wxLANGUAGE_SWEDISH, - wxLANGUAGE_TURKISH, - - wxLANGUAGE_GREEK, - wxLANGUAGE_RUSSIAN, - wxLANGUAGE_ARABIC, - wxLANGUAGE_FARSI, - wxLANGUAGE_KOREAN, - wxLANGUAGE_JAPANESE, - wxLANGUAGE_CHINESE_SIMPLIFIED, - wxLANGUAGE_CHINESE_TRADITIONAL, +static const std::string language_ids[] = { + "", + + "ms", "ca", "cs", "da", "de", "en", "es", "fr", "hr", "it", "hu", "nl", + "nb", // wxWidgets won't accept "no" + "pl", "pt", "pt_BR", "ro", "sr", "sv", "tr", + + "el", "ru", "ar", "fa", "ko", "ja", "zh_CN", "zh_TW", }; InterfaceConfigPane::InterfaceConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id) -- cgit v1.2.3 From f63461175c3e665ecb7b7a51622babbbecce351d Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 12 Aug 2016 14:01:56 +0200 Subject: DolphinWX: Loose language matching in interface config --- .../Core/DolphinWX/Config/InterfaceConfigPane.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp') diff --git a/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp b/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp index 30a3c7aa30..ae1a79ba04 100644 --- a/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include +#include #include #include @@ -12,6 +14,7 @@ #include #include +#include "Common/CommonFuncs.h" #include "Common/CommonPaths.h" #include "Common/FileSearch.h" #include "Common/FileUtil.h" @@ -27,7 +30,7 @@ #include "DolphinWX/X11Utils.h" #endif -static const std::string language_ids[] = { +static const std::array language_ids = { "", "ms", "ca", "cs", "da", "de", "en", "es", "fr", "hr", "it", "hu", "nl", @@ -146,14 +149,26 @@ void InterfaceConfigPane::LoadGUIValues() m_osd_messages_checkbox->SetValue(startup_params.bOnScreenDisplayMessages); m_pause_focus_lost_checkbox->SetValue(SConfig::GetInstance().m_PauseOnFocusLost); - for (size_t i = 0; i < sizeof(language_ids) / sizeof(wxLanguage); i++) + const std::string exact_language = SConfig::GetInstance().m_InterfaceLanguage; + const std::string loose_language = exact_language.substr(0, exact_language.find('_')); + size_t exact_match_index = std::numeric_limits::max(); + size_t loose_match_index = std::numeric_limits::max(); + for (size_t i = 0; i < language_ids.size(); i++) { - if (language_ids[i] == SConfig::GetInstance().m_InterfaceLanguage) + if (language_ids[i] == exact_language) { - m_interface_lang_choice->SetSelection(i); + exact_match_index = i; break; } + else if (language_ids[i] == loose_language) + { + loose_match_index = i; + } } + if (exact_match_index != std::numeric_limits::max()) + m_interface_lang_choice->SetSelection(exact_match_index); + else if (loose_match_index != std::numeric_limits::max()) + m_interface_lang_choice->SetSelection(loose_match_index); LoadThemes(); } -- cgit v1.2.3