Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

GUI: change language selection format to "language - country (locale name)" #1519

Merged
merged 1 commit into from

2 participants

@Diapolo

new language selection

The language and country names are displayed always in english, which seems to be a Qt limitation.

Fixes: #1509

@laanwj
Owner

Great!

I see one mistake in the screenshot though: en (or generally, xx without xx_YY) should be simply English, not English - UnitedStates :)

@Diapolo

@laanwj I'm not sure how to fix your observation, as I pass "en" into QLocale and query .language() and .country(). Perhaps UnitedStates is default here? As Germany is for de?

@laanwj
Owner

Yes, I know that's the behavior. But it's not correct. English is "general" English, without locale. You can see this problem with Persian - Iran, which is now duplicate in the list. I wonder if there is another way to take apart the xx_YY which doesn't have this problem (without reinventing the wheel...).

@Diapolo

We could check if there is a "_" in the source string and if not only use .language()? Do you know the function to check for a certain char in a QString?

@laanwj
Owner

QString::contains(str) -> bool

@Diapolo Diapolo GUI: change language selection format
- display as "language - country (locale name)", when locale name consists of 2 parts
- display as "language (locale name)", when locale name consists of 1 part
2943f60
@Diapolo

@laanwj Thanks, it now does, what we want it to do.

@laanwj
Owner

ACK

@laanwj laanwj merged commit bcf0f41 into bitcoin:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 26, 2012
  1. @Diapolo

    GUI: change language selection format

    Diapolo authored
    - display as "language - country (locale name)", when locale name consists of 2 parts
    - display as "language (locale name)", when locale name consists of 1 part
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 1 deletion.
  1. +14 −1 src/qt/optionsdialog.cpp
View
15 src/qt/optionsdialog.cpp
@@ -14,6 +14,7 @@
#include <QIntValidator>
#include <QLabel>
#include <QLineEdit>
+#include <QLocale>
#include <QMessageBox>
#include <QPushButton>
#include <QRegExp>
@@ -62,7 +63,19 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
foreach(const QString &langStr, translations.entryList())
{
- ui->lang->addItem(langStr, QVariant(langStr));
+ QLocale locale(langStr);
+
+ /** check if the locale name consists of 2 parts (language_country) */
+ if(langStr.contains("_"))
+ {
+ /** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
+ ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
+ }
+ else
+ {
+ /** display language strings as "language (locale name)", e.g. "German (de)" */
+ ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
+ }
}
ui->unit->setModel(new BitcoinUnits(this));
Something went wrong with that request. Please try again.