From b7b183dcb8c85a4af2e577b4021ac37c6d49e761 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 3 Feb 2014 17:04:36 +0000 Subject: [PATCH] Added support for French translation. --- src/api/api.cpp | 1 + src/api/api.h | 2 +- src/backend/globals.cpp | 1 + src/backend/globals.h | 1 + src/backend/helpers.cpp | 4 ++++ src/gui/editor.cpp | 2 +- src/gui/ids.cpp | 11 ++++++++--- src/gui/ids.h | 4 +++- src/gui/main.cpp | 5 +++++ src/gui/settings.cpp | 2 +- 10 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/api/api.cpp b/src/api/api.cpp index b9563b51..7d4cc238 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -77,6 +77,7 @@ const unsigned int boss_lang_any = boss::g_lang_any; const unsigned int boss_lang_english = boss::g_lang_english; const unsigned int boss_lang_spanish = boss::g_lang_spanish; const unsigned int boss_lang_russian = boss::g_lang_russian; +const unsigned int boss_lang_french = boss::g_lang_french; ///< Tells the API to preferentially select French messages. // BOSS cleanliness codes. const unsigned int boss_needs_cleaning_no = 0; diff --git a/src/api/api.h b/src/api/api.h index de15f72d..92b3ee46 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -173,7 +173,7 @@ BOSS_API extern const unsigned int boss_lang_any; ///< Tells the API to select BOSS_API extern const unsigned int boss_lang_english; ///< Tells the API to preferentially select English messages. BOSS_API extern const unsigned int boss_lang_spanish; ///< Tells the API to preferentially select Spanish messages. BOSS_API extern const unsigned int boss_lang_russian; ///< Tells the API to preferentially select Russian messages. - +BOSS_API extern const unsigned int boss_lang_french; ///< Tells the API to preferentially select French messages. ///@} /*********************************//** diff --git a/src/backend/globals.cpp b/src/backend/globals.cpp index 566caf53..3e175d9c 100644 --- a/src/backend/globals.cpp +++ b/src/backend/globals.cpp @@ -44,6 +44,7 @@ namespace boss { const unsigned int g_lang_english = 1; const unsigned int g_lang_spanish = 2; const unsigned int g_lang_russian = 3; + const unsigned int g_lang_french = 4; //Version numbers. const unsigned int g_version_major = 3; diff --git a/src/backend/globals.h b/src/backend/globals.h index 63bf1ead..03331986 100644 --- a/src/backend/globals.h +++ b/src/backend/globals.h @@ -45,6 +45,7 @@ namespace boss { extern const unsigned int g_lang_english; extern const unsigned int g_lang_spanish; extern const unsigned int g_lang_russian; + extern const unsigned int g_lang_french; //Version numbers. extern const unsigned int g_version_major; diff --git a/src/backend/helpers.cpp b/src/backend/helpers.cpp index e69a4f44..8c042c97 100644 --- a/src/backend/helpers.cpp +++ b/src/backend/helpers.cpp @@ -239,6 +239,8 @@ namespace boss { return "spa"; else if (num == g_lang_russian) return "rus"; + else if (num == g_lang_french) + return "fra"; else return ""; } @@ -250,6 +252,8 @@ namespace boss { return g_lang_spanish; else if (boost::iequals(str, "rus")) return g_lang_russian; + else if (boost::iequals(str, "fra")) + return g_lang_french; else return g_lang_any; } diff --git a/src/gui/editor.cpp b/src/gui/editor.cpp index cda05a8a..0e55878d 100644 --- a/src/gui/editor.cpp +++ b/src/gui/editor.cpp @@ -1035,7 +1035,7 @@ MessageEditDialog::MessageEditDialog(wxWindow *parent, const wxString& title) : //Initialise controls. _type = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 3, Type); - _language = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, Language); + _language = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, LanguageSize, Language); _condition = new wxTextCtrl(this, wxID_ANY); _str = new wxTextCtrl(this, wxID_ANY); diff --git a/src/gui/ids.cpp b/src/gui/ids.cpp index 815365c7..2b7cdd55 100644 --- a/src/gui/ids.cpp +++ b/src/gui/ids.cpp @@ -27,11 +27,12 @@ #include #include -wxString Language[4] = { +const wxString Language[LanguageSize] = { translate("None Specified"), wxT("English"), wxString::FromUTF8("Español"), wxString::FromUTF8("Русский"), + wxString::FromUTF8("Français"), }; wxString translate(const std::string& str) { @@ -53,6 +54,8 @@ unsigned int GetLangIndex(const std::string& str) { return 2; else if (boost::iequals(str, "rus")) return 3; + else if (boost::iequals(str, "fra")) + return 4; else return 0; } @@ -64,12 +67,14 @@ std::string GetLangStringFromIndex(const unsigned int index) { return "spa"; else if (index == 3) return "rus"; + else if (index == 4) + return "fra"; else return ""; } unsigned int GetLangNum(const wxString& str) { - for (int i=0; i < 4; ++i) { + for (int i = 0; i < LanguageSize; ++i) { if (str == Language[i]) return GetLangNum(GetLangStringFromIndex(i)); } @@ -77,7 +82,7 @@ unsigned int GetLangNum(const wxString& str) { } unsigned int GetLangIndex(const wxString& str) { - for (int i=0; i < 4; ++i) { + for (int i = 0; i < LanguageSize; ++i) { if (str == Language[i]) return i; } diff --git a/src/gui/ids.h b/src/gui/ids.h index 5f9fe106..08712bdd 100644 --- a/src/gui/ids.h +++ b/src/gui/ids.h @@ -74,7 +74,9 @@ enum { BUTTON_MoveDown, }; -extern wxString Language[4]; +const unsigned int LanguageSize = 5; + +extern const wxString Language[LanguageSize]; wxString translate(const std::string& str); diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 80a101d2..851713dc 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -249,6 +249,11 @@ bool BossGUI::OnInit() { localeId = "ru.UTF-8"; lang = wxLANGUAGE_RUSSIAN; } + else if (_settings["Language"].as() == "fra") { + BOOST_LOG_TRIVIAL(debug) << "Selected language: French."; + localeId = "fr.UTF-8"; + lang = wxLANGUAGE_FRENCH; + } } //Boost.Locale initialisation: Specify location of language dictionaries. diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 2e51612b..a98308df 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -51,7 +51,7 @@ SettingsFrame::SettingsFrame(wxWindow *parent, const wxString& title, YAML::Node //Initialise controls. GameChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, Games); - LanguageChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, Language); + LanguageChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, LanguageSize, Language); DebugVerbosityChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, DebugVerbosity); gamesList = new wxListView(this, LIST_Games, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL);