aboutsummaryrefslogtreecommitdiff
path: root/src/mnemonics
diff options
context:
space:
mode:
Diffstat (limited to 'src/mnemonics')
-rw-r--r--src/mnemonics/chinese_simplified.h2
-rw-r--r--src/mnemonics/dutch.h2
-rw-r--r--src/mnemonics/electrum-words.cpp34
-rw-r--r--src/mnemonics/electrum-words.h10
-rw-r--r--src/mnemonics/english.h2
-rw-r--r--src/mnemonics/english_old.h2
-rw-r--r--src/mnemonics/esperanto.h2
-rw-r--r--src/mnemonics/french.h2
-rw-r--r--src/mnemonics/german.h2
-rw-r--r--src/mnemonics/italian.h2
-rw-r--r--src/mnemonics/japanese.h2
-rw-r--r--src/mnemonics/language_base.h14
-rw-r--r--src/mnemonics/lojban.h2
-rw-r--r--src/mnemonics/portuguese.h2
-rw-r--r--src/mnemonics/russian.h2
-rw-r--r--src/mnemonics/spanish.h2
16 files changed, 60 insertions, 24 deletions
diff --git a/src/mnemonics/chinese_simplified.h b/src/mnemonics/chinese_simplified.h
index dd5548ba2..1ae8c89d6 100644
--- a/src/mnemonics/chinese_simplified.h
+++ b/src/mnemonics/chinese_simplified.h
@@ -72,7 +72,7 @@ namespace Language
class Chinese_Simplified: public Base
{
public:
- Chinese_Simplified(): Base("简体中文 (中国)", std::vector<std::string>({
+ Chinese_Simplified(): Base("简体中文 (中国)", "Chinese (simplified)", std::vector<std::string>({
"的",
"一",
"是",
diff --git a/src/mnemonics/dutch.h b/src/mnemonics/dutch.h
index 43185cd1d..c9806f450 100644
--- a/src/mnemonics/dutch.h
+++ b/src/mnemonics/dutch.h
@@ -49,7 +49,7 @@ namespace Language
class Dutch: public Base
{
public:
- Dutch(): Base("Nederlands", std::vector<std::string>({
+ Dutch(): Base("Nederlands", "Dutch", std::vector<std::string>({
"aalglad",
"aalscholver",
"aambeeld",
diff --git a/src/mnemonics/electrum-words.cpp b/src/mnemonics/electrum-words.cpp
index f1fef2426..6a2a3e0c4 100644
--- a/src/mnemonics/electrum-words.cpp
+++ b/src/mnemonics/electrum-words.cpp
@@ -445,13 +445,9 @@ namespace crypto
return bytes_to_words(src.data, sizeof(src), words, language_name);
}
- /*!
- * \brief Gets a list of seed languages that are supported.
- * \param languages The vector is set to the list of languages.
- */
- void get_language_list(std::vector<std::string> &languages)
+ std::vector<const Language::Base*> get_language_list()
{
- std::vector<Language::Base*> language_instances({
+ static const std::vector<const Language::Base*> language_instances({
Language::Singleton<Language::German>::instance(),
Language::Singleton<Language::English>::instance(),
Language::Singleton<Language::Spanish>::instance(),
@@ -465,10 +461,20 @@ namespace crypto
Language::Singleton<Language::Esperanto>::instance(),
Language::Singleton<Language::Lojban>::instance()
});
- for (std::vector<Language::Base*>::iterator it = language_instances.begin();
+ return language_instances;
+ }
+
+ /*!
+ * \brief Gets a list of seed languages that are supported.
+ * \param languages The vector is set to the list of languages.
+ */
+ void get_language_list(std::vector<std::string> &languages, bool english)
+ {
+ const std::vector<const Language::Base*> language_instances = get_language_list();
+ for (std::vector<const Language::Base*>::const_iterator it = language_instances.begin();
it != language_instances.end(); it++)
{
- languages.push_back((*it)->get_language_name());
+ languages.push_back(english ? (*it)->get_english_language_name() : (*it)->get_language_name());
}
}
@@ -485,6 +491,18 @@ namespace crypto
return word_list.size() != (seed_length + 1);
}
+ std::string get_english_name_for(const std::string &name)
+ {
+ const std::vector<const Language::Base*> language_instances = get_language_list();
+ for (std::vector<const Language::Base*>::const_iterator it = language_instances.begin();
+ it != language_instances.end(); it++)
+ {
+ if ((*it)->get_language_name() == name)
+ return (*it)->get_english_language_name();
+ }
+ return "<language not found>";
+ }
+
}
}
diff --git a/src/mnemonics/electrum-words.h b/src/mnemonics/electrum-words.h
index 48ee378c0..856edb92a 100644
--- a/src/mnemonics/electrum-words.h
+++ b/src/mnemonics/electrum-words.h
@@ -106,8 +106,9 @@ namespace crypto
/*!
* \brief Gets a list of seed languages that are supported.
* \param languages A vector is set to the list of languages.
+ * \param english whether to get the names in English or the language language
*/
- void get_language_list(std::vector<std::string> &languages);
+ void get_language_list(std::vector<std::string> &languages, bool english = false);
/*!
* \brief Tells if the seed passed is an old style seed or not.
@@ -115,6 +116,13 @@ namespace crypto
* \return true if the seed passed is a old style seed false if not.
*/
bool get_is_old_style_seed(std::string seed);
+
+ /*!
+ * \brief Returns the name of a language in English
+ * \param name the name of the language in its own language
+ * \return the name of the language in English
+ */
+ std::string get_english_name_for(const std::string &name);
}
}
diff --git a/src/mnemonics/english.h b/src/mnemonics/english.h
index d4a89ebbc..ee087674d 100644
--- a/src/mnemonics/english.h
+++ b/src/mnemonics/english.h
@@ -49,7 +49,7 @@ namespace Language
class English: public Base
{
public:
- English(): Base("English", std::vector<std::string>({
+ English(): Base("English", "English", std::vector<std::string>({
"abbey",
"abducts",
"ability",
diff --git a/src/mnemonics/english_old.h b/src/mnemonics/english_old.h
index 8866c8d71..b31491646 100644
--- a/src/mnemonics/english_old.h
+++ b/src/mnemonics/english_old.h
@@ -51,7 +51,7 @@ namespace Language
class EnglishOld: public Base
{
public:
- EnglishOld(): Base("EnglishOld", std::vector<std::string>({
+ EnglishOld(): Base("EnglishOld", "English (old)", std::vector<std::string>({
"like",
"just",
"love",
diff --git a/src/mnemonics/esperanto.h b/src/mnemonics/esperanto.h
index 21ee4c9f1..cb377a58e 100644
--- a/src/mnemonics/esperanto.h
+++ b/src/mnemonics/esperanto.h
@@ -58,7 +58,7 @@ namespace Language
class Esperanto: public Base
{
public:
- Esperanto(): Base("Esperanto", std::vector<std::string>({
+ Esperanto(): Base("Esperanto", "Esperanto", std::vector<std::string>({
"abako",
"abdiki",
"abelo",
diff --git a/src/mnemonics/french.h b/src/mnemonics/french.h
index a472263b3..7eaf45650 100644
--- a/src/mnemonics/french.h
+++ b/src/mnemonics/french.h
@@ -49,7 +49,7 @@ namespace Language
class French: public Base
{
public:
- French(): Base("Français", std::vector<std::string>({
+ French(): Base("Français", "French", std::vector<std::string>({
"abandon",
"abattre",
"aboi",
diff --git a/src/mnemonics/german.h b/src/mnemonics/german.h
index 01c483664..8eff43523 100644
--- a/src/mnemonics/german.h
+++ b/src/mnemonics/german.h
@@ -51,7 +51,7 @@ namespace Language
class German: public Base
{
public:
- German(): Base("Deutsch", std::vector<std::string>({
+ German(): Base("Deutsch", "German", std::vector<std::string>({
"Abakus",
"Abart",
"abbilden",
diff --git a/src/mnemonics/italian.h b/src/mnemonics/italian.h
index f9536e2dd..d5ecb74f4 100644
--- a/src/mnemonics/italian.h
+++ b/src/mnemonics/italian.h
@@ -51,7 +51,7 @@ namespace Language
class Italian: public Base
{
public:
- Italian(): Base("Italiano", std::vector<std::string>({
+ Italian(): Base("Italiano", "Italian", std::vector<std::string>({
"abbinare",
"abbonato",
"abisso",
diff --git a/src/mnemonics/japanese.h b/src/mnemonics/japanese.h
index 5b5884c3b..f3b3e4924 100644
--- a/src/mnemonics/japanese.h
+++ b/src/mnemonics/japanese.h
@@ -71,7 +71,7 @@ namespace Language
class Japanese: public Base
{
public:
- Japanese(): Base("日本語", std::vector<std::string>({
+ Japanese(): Base("日本語", "Japanese", std::vector<std::string>({
"あいこくしん",
"あいさつ",
"あいだ",
diff --git a/src/mnemonics/language_base.h b/src/mnemonics/language_base.h
index 2124b8ea4..2b0c37c6b 100644
--- a/src/mnemonics/language_base.h
+++ b/src/mnemonics/language_base.h
@@ -82,6 +82,7 @@ namespace Language
std::unordered_map<std::string, uint32_t> word_map; /*!< hash table to find word's index */
std::unordered_map<std::string, uint32_t> trimmed_word_map; /*!< hash table to find word's trimmed index */
std::string language_name; /*!< Name of language */
+ std::string english_language_name; /*!< Name of language */
uint32_t unique_prefix_length; /*!< Number of unique starting characters to trim the wordlist to when matching */
/*!
* \brief Populates the word maps after the list is ready.
@@ -122,10 +123,11 @@ namespace Language
}
}
public:
- Base(const char *language_name, const std::vector<std::string> &words, uint32_t prefix_length):
+ Base(const char *language_name, const char *english_language_name, const std::vector<std::string> &words, uint32_t prefix_length):
word_list(words),
unique_prefix_length(prefix_length),
- language_name(language_name)
+ language_name(language_name),
+ english_language_name(english_language_name)
{
}
virtual ~Base()
@@ -164,6 +166,14 @@ namespace Language
return language_name;
}
/*!
+ * \brief Returns the name of the language in English.
+ * \return Name of the language.
+ */
+ const std::string &get_english_language_name() const
+ {
+ return english_language_name;
+ }
+ /*!
* \brief Returns the number of unique starting characters to be used for matching.
* \return Number of unique starting characters.
*/
diff --git a/src/mnemonics/lojban.h b/src/mnemonics/lojban.h
index 723f1eac0..412531a23 100644
--- a/src/mnemonics/lojban.h
+++ b/src/mnemonics/lojban.h
@@ -56,7 +56,7 @@ namespace Language
class Lojban: public Base
{
public:
- Lojban(): Base("Lojban", std::vector<std::string>({
+ Lojban(): Base("Lojban", "Lojban", std::vector<std::string>({
"backi",
"bacru",
"badna",
diff --git a/src/mnemonics/portuguese.h b/src/mnemonics/portuguese.h
index f68716962..0195389ce 100644
--- a/src/mnemonics/portuguese.h
+++ b/src/mnemonics/portuguese.h
@@ -72,7 +72,7 @@ namespace Language
class Portuguese: public Base
{
public:
- Portuguese(): Base("Português", std::vector<std::string>({
+ Portuguese(): Base("Português", "Portuguese", std::vector<std::string>({
"abaular",
"abdominal",
"abeto",
diff --git a/src/mnemonics/russian.h b/src/mnemonics/russian.h
index 749191c9b..d5dd556ef 100644
--- a/src/mnemonics/russian.h
+++ b/src/mnemonics/russian.h
@@ -51,7 +51,7 @@ namespace Language
class Russian: public Base
{
public:
- Russian(): Base("русский язык", std::vector<std::string>({
+ Russian(): Base("русский язык", "Russian", std::vector<std::string>({
"абажур",
"абзац",
"абонент",
diff --git a/src/mnemonics/spanish.h b/src/mnemonics/spanish.h
index 0c581128e..51f38fede 100644
--- a/src/mnemonics/spanish.h
+++ b/src/mnemonics/spanish.h
@@ -72,7 +72,7 @@ namespace Language
class Spanish: public Base
{
public:
- Spanish(): Base("Español", std::vector<std::string>({
+ Spanish(): Base("Español", "Spanish", std::vector<std::string>({
"ábaco",
"abdomen",
"abeja",