Port emojier away from deprecated I18N_NOOP

This is rather dirty, the category table should hold KLazyLocalizedString
instances rather than QStrings of the untranslated message, and actual
translation should be done by calling toString() on those, to avoid
duplicating the context.

That however isn't easily possible here as the translation happens on the
QML side, after using the untranslated string in a mapping table for icons.
So this has to do for now.
This commit is contained in:
Volker Krause 2022-10-09 11:08:23 +02:00
parent 5f24d9347f
commit 2d8a9c30b9
2 changed files with 17 additions and 11 deletions

View file

@ -106,6 +106,9 @@ class EmojiParser(object):
*/
// Generated from emoji-test.txt
#include "emojicategory.h"
#include <KLazyLocalizedString>
const QStringList &getCategoryNames()
{
static const QStringList names = {'''
@ -113,7 +116,7 @@ const QStringList &getCategoryNames()
return names;
}
'''
content = "\n".join([template_header] + [f" I18N_NOOP2(\"Emoji Category\", \"{categoryName.decode('utf-8')}\")," for categoryName in self.categoryNames] + [template_foot])
content = "\n".join([template_header] + [f" QString::fromUtf8(kli18nc(\"Emoji Category\", \"{categoryName.decode('utf-8')}\").untranslatedText())," for categoryName in self.categoryNames] + [template_foot])
with open("../emojicategory.cpp", "w") as f:
f.write(content)

View file

@ -5,19 +5,22 @@
*/
// Generated from emoji-test.txt
#include "emojicategory.h"
#include <KLazyLocalizedString>
const QStringList &getCategoryNames()
{
static const QStringList names = {
I18N_NOOP2("Emoji Category", "Smileys and Emotion"),
I18N_NOOP2("Emoji Category", "People and Body"),
I18N_NOOP2("Emoji Category", "Component"),
I18N_NOOP2("Emoji Category", "Animals and Nature"),
I18N_NOOP2("Emoji Category", "Food and Drink"),
I18N_NOOP2("Emoji Category", "Travel and Places"),
I18N_NOOP2("Emoji Category", "Activities"),
I18N_NOOP2("Emoji Category", "Objects"),
I18N_NOOP2("Emoji Category", "Symbols"),
I18N_NOOP2("Emoji Category", "Flags"),
QString::fromUtf8(kli18nc("Emoji Category", "Smileys and Emotion").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "People and Body").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Component").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Animals and Nature").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Food and Drink").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Travel and Places").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Activities").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Objects").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Symbols").untranslatedText()),
QString::fromUtf8(kli18nc("Emoji Category", "Flags").untranslatedText()),
};
return names;
}