summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp
diff options
context:
space:
mode:
authorshuffle2 <godisgovernment@gmail.com>2016-10-02 21:23:36 -0700
committerGitHub <noreply@github.com>2016-10-02 21:23:36 -0700
commit0082fa527b2d7df72196cd838a718e832cfbfe70 (patch)
tree874a5b24d3cc293bd8eff5c2ffe60f2290b31b2c /Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp
parentf71966866bab11b02a0a8b26c549106d1b6bc425 (diff)
parentf63461175c3e665ecb7b7a51622babbbecce351d (diff)
Merge pull request #4117 from JosJuice/wx-language-code
Save GUI language as string instead of wxLanguage enum
Diffstat (limited to 'Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp')
-rw-r--r--Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp61
1 files changed, 26 insertions, 35 deletions
diff --git a/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp b/Source/Core/DolphinWX/Config/InterfaceConfigPane.cpp
index a3934c9b8f..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 <array>
+#include <limits>
#include <string>
#include <wx/button.h>
@@ -12,6 +14,7 @@
#include <wx/sizer.h>
#include <wx/stattext.h>
+#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/FileSearch.h"
#include "Common/FileUtil.h"
@@ -27,38 +30,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::array<std::string, 29> 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)
@@ -170,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<size_t>::max();
+ size_t loose_match_index = std::numeric_limits<size_t>::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<size_t>::max())
+ m_interface_lang_choice->SetSelection(exact_match_index);
+ else if (loose_match_index != std::numeric_limits<size_t>::max())
+ m_interface_lang_choice->SetSelection(loose_match_index);
LoadThemes();
}