mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Port away from QLocale:Country related code
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
b456c18bf6
commit
60d14cb487
@ -99,7 +99,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
|
|||||||
label = tr("Personal [%1]").arg(code);
|
label = tr("Personal [%1]").arg(code);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
label = QSL("%1/%2 [%3]").arg(loc.languageToString(loc.language()), loc.countryToString(loc.country()), code);
|
label = QSL("%1/%2 [%3]").arg(loc.languageToString(loc.language()), loc.territoryToString(loc.territory()), code);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->listWidget->addItem(label);
|
ui->listWidget->addItem(label);
|
||||||
@ -114,27 +114,29 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
|
|||||||
QStringList AcceptLanguage::expand(const QLocale::Language &language)
|
QStringList AcceptLanguage::expand(const QLocale::Language &language)
|
||||||
{
|
{
|
||||||
QStringList allLanguages;
|
QStringList allLanguages;
|
||||||
QList<QLocale::Country> countries = QLocale::countriesForLanguage(language);
|
const QList<QLocale> locales = QLocale::matchingLocales(language, QLocale::AnyScript, QLocale::AnyTerritory);
|
||||||
for (int j = 0; j < countries.size(); ++j) {
|
for (const QLocale &locale : locales) {
|
||||||
QString languageString;
|
QString languageString;
|
||||||
if (countries.count() == 1) {
|
|
||||||
|
if (locales.count() == 1) {
|
||||||
languageString = QString(QLatin1String("%1 [%2]")).arg(
|
languageString = QString(QLatin1String("%1 [%2]")).arg(
|
||||||
QLocale::languageToString(language),
|
QLocale::languageToString(locale.language()),
|
||||||
QLocale(language).name().split(QLatin1Char('_')).at(0)
|
locale.name().split(QL1C('_')).at(0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
languageString = QString(QLatin1String("%1/%2 [%3]")).arg (
|
languageString = QString(QLatin1String("%1/%2 [%3]")).arg (
|
||||||
QLocale::languageToString(language),
|
QLocale::languageToString(locale.language()),
|
||||||
QLocale::countryToString(countries.at(j)),
|
QLocale::territoryToString(locale.territory()),
|
||||||
QLocale(language, countries.at(j)).name().split(QLatin1Char('_')).join(QLatin1Char('-')).toLower()
|
locale.name().replace(QL1C('_'), QL1C('-')).toLower()
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allLanguages.contains(languageString)) {
|
if (!allLanguages.contains(languageString)) {
|
||||||
allLanguages.append(languageString);
|
allLanguages.append(languageString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allLanguages;
|
return allLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +220,7 @@ void AcceptLanguage::accept()
|
|||||||
Settings settings;
|
Settings settings;
|
||||||
settings.beginGroup(QSL("Language"));
|
settings.beginGroup(QSL("Language"));
|
||||||
settings.setValue(QSL("acceptLanguage"), langs);
|
settings.setValue(QSL("acceptLanguage"), langs);
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
mApp->networkManager()->loadSettings();
|
mApp->networkManager()->loadSettings();
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ static QString createLanguageItem(const QString &lang)
|
|||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString country = QLocale::countryToString(locale.country());
|
const QString territory = QLocale::territoryToString(locale.territory());
|
||||||
const QString language = QLocale::languageToString(locale.language());
|
const QString language = QLocale::languageToString(locale.language());
|
||||||
|
|
||||||
if (lang == QLatin1String("es_ES")) {
|
if (lang == QLatin1String("es_ES")) {
|
||||||
@ -93,7 +93,7 @@ static QString createLanguageItem(const QString &lang)
|
|||||||
if (lang == QLatin1String("sr@ijekavianlatin")) {
|
if (lang == QLatin1String("sr@ijekavianlatin")) {
|
||||||
return QString::fromUtf8("srpski ijekavski");
|
return QString::fromUtf8("srpski ijekavski");
|
||||||
}
|
}
|
||||||
return QStringLiteral("%1, %2 (%3)").arg(language, country, lang);
|
return QStringLiteral("%1, %2 (%3)").arg(language, territory, lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences::Preferences(BrowserWindow* window)
|
Preferences::Preferences(BrowserWindow* window)
|
||||||
|
Loading…
Reference in New Issue
Block a user