Summary: | Cannot see translators' names | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kcoreaddons | Reporter: | Alexander Potashev <aspotashev> |
Component: | general | Assignee: | Michael Pyne <mpyne> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | karl, kdelibs-bugs, smart2128vr, Thomas.Eschenbacher |
Priority: | NOR | Flags: | aspotashev:
Translation_missing+
|
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | http://commits.kde.org/kxmlgui/e4d10c796ae8a3a7ecc6e7a338d6126259fa2583 | Version Fixed In: | 5.16 |
Sentry Crash Report: |
Description
Alexander Potashev
2015-03-19 00:47:45 UTC
I can confirm the bug reported by Alexander. No "Translation" tab in the About dialog. 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. 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. 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())); } } } ------------------------------------------------------------------------------------ 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. 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 |