[graphics/krita/krita/5.2] libs/ui: Add missing languages to feed button
Halla Rempt
null at kde.org
Wed Sep 4 10:03:40 BST 2024
Git commit 055329c53e948c0e6065ffbad0e77471ea7868b8 by Halla Rempt.
Committed on 04/09/2024 at 09:03.
Pushed by rempt into branch 'krita/5.2'.
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
(cherry picked from commit ae318ad7aeeca1db32c619aa63cccdc5f59f5608)
M +20 -31 libs/ui/KisWelcomePageWidget.cpp
M +1 -1 libs/ui/widgets/KisNewsWidget.cpp
https://invent.kde.org/graphics/krita/-/commit/055329c53e948c0e6065ffbad0e77471ea7868b8
diff --git a/libs/ui/KisWelcomePageWidget.cpp b/libs/ui/KisWelcomePageWidget.cpp
index ab017655c6e..d9a13f6f69e 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