Bug 345320 - Cannot see translators' names
Summary: Cannot see translators' names
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-19 00:47 UTC by Alexander Potashev
Modified: 2015-10-22 00:31 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.16
aspotashev: Translation_missing+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Potashev 2015-03-19 00:47:45 UTC
Switch Plasma5 language to something but English and open any KF5-based application (e.g. Dolphin) to make sure there is no tab "Translation" in the "About Dolphin" dialog.

I guess the problem is in KAboutData::translators() in kcoreaddons/src/lib/kaboutdata.cpp: you call QCoreApplication::translate("KAboutPerson", "Your names", ...) to get the list of translators but the actual string "Your names"...
 1. ... comes from a .po files shipped with the application - dolphin.po in the case of Dolphin. Not sure if QCoreApplication::translate() adopts the data from .po files.
 2. ... does not have the "KAboutPerson" context.

Reproducible: Always
Comment 1 Vincenzo Reale 2015-05-11 05:47:59 UTC
I can confirm the bug reported by Alexander.
No "Translation" tab in the About dialog.
Comment 2 Alexander Potashev 2015-05-11 17:50:12 UTC
Strangely the list of translators is there in the "Help->About Editor Component" dialog in Kate. It may be using a codebase separate from KF5.
Comment 3 Thomas Eschenbacher 2015-10-16 05:21:44 UTC
I can also confirm this bug, and digged a bit in the sources...

The root cause seems to be that QCoreApplication::translate(...) in general seems to be broken for any KDE application. If you look at the source code of that function you can see that it iterates over a list of "translators", which is an empty list for a KDE application. Even if you try to follow the documentation and try to install a translator in main(), you will see that you need a Qt style message catalog - but such a file does not exist and I am not willing to provide and maintain two different types of message catalogs - IMO it hast to work with one.

Just for verification, you can put the following code snippet into your main() before calling app.exec():

    #define NAME_OF_TRANSLATORS "Your names"
    QString name;
    name = QCoreApplication::translate("KAboutPerson", NAME_OF_TRANSLATORS, "NAME OF TRANSLATORS");
    qDebug("this fails: '%s'", name.toLocal8Bit().data());
    name = QObject::tr(NAME_OF_TRANSLATORS);
    qDebug("this fails: '%s'", name.toLocal8Bit().data());
    qDebug("this works: '%s'", i18n(NAME_OF_TRANSLATORS).toLocal8Bit().data());

=> IMO the code of KAboutData::translators() should be changed to use i18nc or similar.
Comment 4 Thomas Eschenbacher 2015-10-17 11:54:47 UTC
update:

This seems to be broken by design.

The current code within the kcoreaddons package uses QCoreApplication::translate(...), which only works with Qt translation files (*.qm). As the package provides such a file, all strings that come from this package are translated, for example KAboutData::aboutTranslationTeam() works fine and returns a translated string.

But most KDE applications do not provide *.qm files, they work with GNU message catalogs (*.mo files). As these two systems are incompatible it cannot work. I tried to find a patch for this, using direct calls from libintl, but with no luck. I was able translate "normal" texts (those without context) with directly calling dcgettext(...), but for the ones with context (as used for NAME_OF_TRANSLATORS from above) it did not work. Maybe it would work by using dcpgettext(...), but that function is not available here.

=> so how could this be solved?
maybe move KAboutData to a different sub package (non-tier-1), to allow it to use things like ki18nc(...) ?

in my application I worked around by duplicating the code and using ki18nc :
------------------------------------------------------------------------------------
    QList<KAboutPerson> translators = about_data.translators(); // <- currently broken, returns empty list

    if (translators.isEmpty()) {
	QString names  = ki18nc("NAME OF TRANSLATORS", NAME_OF_TRANSLATORS).toString();
	QString emails = ki18nc("EMAIL OF TRANSLATORS", EMAIL_OF_TRANSLATORS).toString();

	if (!names.isEmpty() && (names != _(NAME_OF_TRANSLATORS))) {
	    const QStringList list_names(names.split(_(",")));

	    QStringList list_emails;
	    if (!emails.isEmpty() && (emails != _(EMAIL_OF_TRANSLATORS)))
		list_emails = emails.split(_(","), QString::KeepEmptyParts);

	    QStringList::const_iterator it_e = list_emails.constBegin();
	    foreach (const QString &name, list_names) {
		QString email;
		if (it_e != list_emails.constEnd())
		    email = *(it_e++);
		translators.append(KAboutPerson(name.trimmed(), QString(), email.trimmed()));
	    }
	}
    }
------------------------------------------------------------------------------------
Comment 5 Michael Pyne 2015-10-17 18:56:42 UTC
I'm not really sure what to do with this, the translation infrastructure isn't really my area of expertise. :(

What I will do is ask for help from frameworks-devel and see whether we can either adapt the translation context, move KAboutData, or some other suitable fix.
Comment 6 Michael Pyne 2015-10-22 00:31:34 UTC
Git commit e4d10c796ae8a3a7ecc6e7a338d6126259fa2583 by Michael Pyne.
Committed on 22/10/2015 at 00:25.
Pushed by mpyne into branch 'master'.

kmainwindow: Pre-fill translator information when available.

KCoreAddons's KAboutData can store information about the translators for
the application when using non-en_US messages. This information is
encoded by translating a specific message string, which can no longer be
done within KAboutData (compared to KDE 4) since KCoreAddons can't use
KI18n.

Applications have been able to manually add translator information, but
there's no reason we can't do this by default for the majority of
our KF5-based applications.

Combined with updates to the KAboutData API documentation I believe this
should also fix bug 345320.
FIXED-IN:5.16
REVIEW:125682

M  +13   -0    src/kmainwindow.cpp
M  +6    -0    src/kmainwindow.h

http://commits.kde.org/kxmlgui/e4d10c796ae8a3a7ecc6e7a338d6126259fa2583