diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp index 7dd09ecb9..19a9c26bb 100644 --- a/src/mnemonics/electrum-words.cpp +++ b/src/mnemonics/electrum-words.cpp @@ -70,6 +70,14 @@ #undef MONERO_DEFAULT_LOG_CATEGORY #define MONERO_DEFAULT_LOG_CATEGORY "mnemonic" +namespace crypto +{ + namespace ElectrumWords + { + std::vector get_language_list(); + } +} + namespace { uint32_t create_checksum_index(const std::vector &word_list, @@ -376,56 +384,14 @@ namespace crypto if (len % 4 != 0 || len == 0) return false; - Language::Base *language; - if (language_name == "English") + const Language::Base *language = NULL; + const std::vector language_list = crypto::ElectrumWords::get_language_list(); + for (const Language::Base *l: language_list) { - language = Language::Singleton::instance(); + if (language_name == l->get_language_name() || language_name == l->get_english_language_name()) + language = l; } - else if (language_name == "Nederlands") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Français") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Español") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Português") - { - language = Language::Singleton::instance(); - } - else if (language_name == "日本語") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Italiano") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Deutsch") - { - language = Language::Singleton::instance(); - } - else if (language_name == "русский язык") - { - language = Language::Singleton::instance(); - } - else if (language_name == "简体中文 (中国)") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Esperanto") - { - language = Language::Singleton::instance(); - } - else if (language_name == "Lojban") - { - language = Language::Singleton::instance(); - } - else + if (!language) { return false; } diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 193b62571..751b88545 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -3344,14 +3344,16 @@ bool simple_wallet::try_connect_to_daemon(bool silent, uint32_t* version) */ std::string simple_wallet::get_mnemonic_language() { - std::vector language_list; + std::vector language_list_self, language_list_english; + const std::vector &language_list = m_use_english_language_names ? language_list_english : language_list_self; std::string language_choice; int language_number = -1; - crypto::ElectrumWords::get_language_list(language_list, m_use_english_language_names); + crypto::ElectrumWords::get_language_list(language_list_self, false); + crypto::ElectrumWords::get_language_list(language_list_english, true); std::cout << tr("List of available languages for your wallet's seed:") << std::endl; std::cout << tr("If your display freezes, exit blind with ^C, then run again with --use-english-language-names") << std::endl; int ii; - std::vector::iterator it; + std::vector::const_iterator it; for (it = language_list.begin(), ii = 0; it != language_list.end(); it++, ii++) { std::cout << ii << " : " << *it << std::endl; @@ -3375,7 +3377,7 @@ std::string simple_wallet::get_mnemonic_language() fail_msg_writer() << tr("invalid language choice entered. Please try again.\n"); } } - return language_list[language_number]; + return language_list_self[language_number]; } //---------------------------------------------------------------------------------------------------- boost::optional simple_wallet::get_and_verify_password() const