[graphics/krita] libs/ui: Add missing languages to feed button
Halla Rempt
null at kde.org
Wed Sep 4 10:03:12 BST 2024
Git commit ae318ad7aeeca1db32c619aa63cccdc5f59f5608 by Halla Rempt.
Committed on 04/09/2024 at 09:01.
Pushed by rempt into branch 'master'.
Add missing languages to feed button
All these languages have a news.po, so they should have a feed.
However, the news widget still cannot actually load the feeds,
either the url we generate (krita.org/pt/feed, for instance) is
wrong, or the hugo configuration for multilang rss feeds is
wrong.
CCMAIL:kimageshop at kde.org
CCBUG:489477
M +20 -31 libs/ui/KisWelcomePageWidget.cpp
M +1 -1 libs/ui/widgets/KisNewsWidget.cpp
https://invent.kde.org/graphics/krita/-/commit/ae318ad7aeeca1db32c619aa63cccdc5f59f5608
diff --git a/libs/ui/KisWelcomePageWidget.cpp b/libs/ui/KisWelcomePageWidget.cpp
index ce1f4b4ef79..4691fc9da65 100644
--- a/libs/ui/KisWelcomePageWidget.cpp
+++ b/libs/ui/KisWelcomePageWidget.cpp
@@ -512,39 +512,11 @@ bool KisWelcomePageWidget::eventFilter(QObject *watched, QEvent *event)
namespace {
-QString mapKi18nLangToNewsLang(const QString &ki18nLang) {
- if (ki18nLang == "ja") {
- return QString("jp");
- }
- if (ki18nLang == "zh_CN") {
- return QString("zh");
- }
- if (ki18nLang == "zh_TW") {
- return QString("zh-tw");
- }
- if (ki18nLang == "zh_HK") {
- return QString("zh-hk");
- }
- if (ki18nLang == "en" || ki18nLang == "en_US" || ki18nLang == "en_GB") {
- return QString("en");
- }
- return QString();
-};
-
QString getAutoNewsLang()
{
// Get current UI languages:
const QStringList uiLangs = KLocalizedString::languages();
-
- QString autoNewsLang;
- // Iterate UI languages including fallback languages for the first
- // available news language.
- Q_FOREACH(const auto &uiLang, uiLangs) {
- autoNewsLang = mapKi18nLangToNewsLang(uiLang);
- if (!autoNewsLang.isEmpty()) {
- break;
- }
- }
+ QString autoNewsLang = uiLangs.first();
if (autoNewsLang.isEmpty()) {
// If nothing else, use English.
autoNewsLang = QString("en");
@@ -558,19 +530,36 @@ void KisWelcomePageWidget::setupNewsLangSelection(QMenu *newsOptionsMenu)
{
// Hard-coded news language data:
// These are languages in which the news items should be regularly
- // translated into as of 2020-11-07.
+ // translated into as of 04-09-2024.
// The language display names should not be translated. This reflects
// the language selection box on the Krita website.
struct Lang {
const QString siteCode;
const QString name;
};
- static const std::array<Lang, 5> newsLangs = {{
+ static const std::array<Lang, 22> newsLangs = {{
{QString("en"), QStringLiteral("English")},
{QString("jp"), QStringLiteral("日本語")},
{QString("zh"), QStringLiteral("中文 (简体)")},
{QString("zh-tw"), QStringLiteral("中文 (台灣正體)")},
{QString("zh-hk"), QStringLiteral("廣東話 (香港)")},
+ {QString("ca"), QStringLiteral("Català")},
+ {QString("ca at valencia"), QStringLiteral("Català de Valencia")},
+ {QString("cs"), QStringLiteral("Čeština")},
+ {QString("de"), QStringLiteral("Deutsch")},
+ {QString("eo"), QStringLiteral("Esperanto")},
+ {QString("es"), QStringLiteral("Español")},
+ {QString("eu"), QStringLiteral("Euskara")},
+ {QString("fr"), QStringLiteral("Français")},
+ {QString("it"), QStringLiteral("Italiano")},
+ {QString("lt"), QStringLiteral("lietuvių")},
+ {QString("nl"), QStringLiteral("Nederlands")},
+ {QString("pt"), QStringLiteral("Português")},
+ {QString("sk"), QStringLiteral("Slovenský")},
+ {QString("sl"), QStringLiteral("Slovenski")},
+ {QString("sv"), QStringLiteral("Svenska")},
+ {QString("tr"), QStringLiteral("Türkçe")},
+ {QString("uk"), QStringLiteral("English (UK)")}
}};
static const QString newsLangConfigName = QStringLiteral("FetchNewsLanguages");
diff --git a/libs/ui/widgets/KisNewsWidget.cpp b/libs/ui/widgets/KisNewsWidget.cpp
index f998cbee417..ae73baf95dd 100644
--- a/libs/ui/widgets/KisNewsWidget.cpp
+++ b/libs/ui/widgets/KisNewsWidget.cpp
@@ -118,7 +118,7 @@ void KisNewsWidget::toggleNewsLanguage(QString langCode, bool enabled)
// Sanity check: Since the code is adding the language code directly into
// the URL, this prevents any nasty surprises with malformed URLs.
Q_FOREACH(const char &ch, langCode.toLatin1()) {
- bool isValidChar = (ch >= 'a' && ch <= 'z') || ch == '-';
+ bool isValidChar = (ch >= 'a' && ch <= 'z') || ch == '-' || ch = '@';
if (!isValidChar) {
warnUI << "Ignoring attempt to toggle malformed news lang:" << langCode;
return;
More information about the kimageshop
mailing list