diff options
-rw-r--r-- | src/mnemonics/electrum-words.cpp | 62 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 10 |
2 files changed, 20 insertions, 52 deletions
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<const Language::Base*> get_language_list(); + } +} + namespace { uint32_t create_checksum_index(const std::vector<std::string> &word_list, @@ -376,56 +384,14 @@ namespace crypto if (len % 4 != 0 || len == 0) return false; - Language::Base *language; - if (language_name == "English") - { - language = Language::Singleton<Language::English>::instance(); - } - else if (language_name == "Nederlands") - { - language = Language::Singleton<Language::Dutch>::instance(); - } - else if (language_name == "Français") - { - language = Language::Singleton<Language::French>::instance(); - } - else if (language_name == "Español") - { - language = Language::Singleton<Language::Spanish>::instance(); - } - else if (language_name == "Português") + const Language::Base *language = NULL; + const std::vector<const Language::Base*> language_list = crypto::ElectrumWords::get_language_list(); + for (const Language::Base *l: language_list) { - language = Language::Singleton<Language::Portuguese>::instance(); + if (language_name == l->get_language_name() || language_name == l->get_english_language_name()) + language = l; } - else if (language_name == "日本語") - { - language = Language::Singleton<Language::Japanese>::instance(); - } - else if (language_name == "Italiano") - { - language = Language::Singleton<Language::Italian>::instance(); - } - else if (language_name == "Deutsch") - { - language = Language::Singleton<Language::German>::instance(); - } - else if (language_name == "русский язык") - { - language = Language::Singleton<Language::Russian>::instance(); - } - else if (language_name == "简体中文 (中国)") - { - language = Language::Singleton<Language::Chinese_Simplified>::instance(); - } - else if (language_name == "Esperanto") - { - language = Language::Singleton<Language::Esperanto>::instance(); - } - else if (language_name == "Lojban") - { - language = Language::Singleton<Language::Lojban>::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<std::string> language_list; + std::vector<std::string> language_list_self, language_list_english; + const std::vector<std::string> &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<std::string>::iterator it; + std::vector<std::string>::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<tools::password_container> simple_wallet::get_and_verify_password() const |