mirror of
https://github.com/monero-project/monero.git
synced 2025-10-13 12:30:42 -04:00
simplewallet: new --use-english-language-names flag
On some Windows systems, displaying language names in their own languages freezes the display.
This commit is contained in:
parent
5cd36e48bf
commit
8ea3c4d544
18 changed files with 70 additions and 26 deletions
|
@ -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>({
|
||||
"的",
|
||||
"一",
|
||||
"是",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace Language
|
|||
class Japanese: public Base
|
||||
{
|
||||
public:
|
||||
Japanese(): Base("日本語", std::vector<std::string>({
|
||||
Japanese(): Base("日本語", "Japanese", std::vector<std::string>({
|
||||
"あいこくしん",
|
||||
"あいさつ",
|
||||
"あいだ",
|
||||
|
|
|
@ -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()
|
||||
|
@ -163,6 +165,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.
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Language
|
|||
class Russian: public Base
|
||||
{
|
||||
public:
|
||||
Russian(): Base("русский язык", std::vector<std::string>({
|
||||
Russian(): Base("русский язык", "Russian", std::vector<std::string>({
|
||||
"абажур",
|
||||
"абзац",
|
||||
"абонент",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue