1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

Port away from QLocale:Country related code

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2024-11-23 16:03:22 +01:00
parent b456c18bf6
commit 60d14cb487
2 changed files with 15 additions and 12 deletions

View File

@ -99,7 +99,7 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
label = tr("Personal [%1]").arg(code);
}
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);
@ -114,27 +114,29 @@ AcceptLanguage::AcceptLanguage(QWidget* parent)
QStringList AcceptLanguage::expand(const QLocale::Language &language)
{
QStringList allLanguages;
QList<QLocale::Country> countries = QLocale::countriesForLanguage(language);
for (int j = 0; j < countries.size(); ++j) {
const QList<QLocale> locales = QLocale::matchingLocales(language, QLocale::AnyScript, QLocale::AnyTerritory);
for (const QLocale &locale : locales) {
QString languageString;
if (countries.count() == 1) {
if (locales.count() == 1) {
languageString = QString(QLatin1String("%1 [%2]")).arg(
QLocale::languageToString(language),
QLocale(language).name().split(QLatin1Char('_')).at(0)
QLocale::languageToString(locale.language()),
locale.name().split(QL1C('_')).at(0)
);
}
else {
languageString = QString(QLatin1String("%1/%2 [%3]")).arg (
QLocale::languageToString(language),
QLocale::countryToString(countries.at(j)),
QLocale(language, countries.at(j)).name().split(QLatin1Char('_')).join(QLatin1Char('-')).toLower()
QLocale::languageToString(locale.language()),
QLocale::territoryToString(locale.territory()),
locale.name().replace(QL1C('_'), QL1C('-')).toLower()
);
}
if (!allLanguages.contains(languageString)) {
allLanguages.append(languageString);
}
}
return allLanguages;
}
@ -218,6 +220,7 @@ void AcceptLanguage::accept()
Settings settings;
settings.beginGroup(QSL("Language"));
settings.setValue(QSL("acceptLanguage"), langs);
settings.endGroup();
mApp->networkManager()->loadSettings();

View File

@ -72,7 +72,7 @@ static QString createLanguageItem(const QString &lang)
return lang;
}
const QString country = QLocale::countryToString(locale.country());
const QString territory = QLocale::territoryToString(locale.territory());
const QString language = QLocale::languageToString(locale.language());
if (lang == QLatin1String("es_ES")) {
@ -93,7 +93,7 @@ static QString createLanguageItem(const QString &lang)
if (lang == QLatin1String("sr@ijekavianlatin")) {
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)