Fix extraction of Qt translation-based strings
ClosedPublic

Authored by kossebau on Jun 3 2016, 5:12 PM.

Details

Summary

To extract Qt tr translatable strings from C++ files for Qt5-based projects
$EXTRACT_TR_STRINGS needs to be used, $XGETTEXT_QT has been for kdelibs4-based projects only.
See also https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems#Writing_a_Messages.sh_script

UI files are passed directly to $EXTRACT_TR_STRINGS, not via $EXTRACTRC.

Be more explicit when finding files to not also include files from tools or examples.

Create proper QCoreApplication::translate calls for strings extracted from data files, when used via Qt translation mechanism.

Have separate Messages.sh file for KDE Marble apps in its source folder.

Use consistently i18n() calls in marble-kde source code.

Diff Detail

Repository
R34 Marble
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau updated this revision to Diff 4199.Jun 3 2016, 5:12 PM
kossebau retitled this revision from to Fix extraction of Qt translation-based strings.
kossebau updated this object.
kossebau edited the test plan for this revision. (Show Details)
kossebau set the repository for this revision to R34 Marble.
kossebau added reviewers: Marble, nienhueser.
kossebau added subscribers: Marble, nienhueser, aspotashev and 2 others.
kossebau removed subscribers: nienhueser, Marble.
kossebau updated this revision to Diff 4203.Jun 4 2016, 12:59 AM
kossebau updated this object.

Looking closer, there seems more not correct than just the outdated $XGETTEXT_QT.

aacid added a comment.Jun 5 2016, 10:44 PM

You still need to load the qt catalog, no?

In D1763#32921, @aacid wrote:

You still need to load the qt catalog, no?

Yes, that is what D1764 is about. Hoped separate diffs for different code layers make things less complex :)

aacid added a comment.Jun 5 2016, 11:36 PM
In D1763#32921, @aacid wrote:

You still need to load the qt catalog, no?

Yes, that is what D1764 is about. Hoped separate diffs for different code layers make things less complex :)

Ok, do we care about all those TODO you added?

kossebau updated this revision to Diff 4262.Jun 6 2016, 11:10 PM
kossebau updated this object.

Tried to solve remaining TODOs for strings extracted from data files.
Also separated marble.pot file creation into own Messages.sh in the KDE apps folder.
Merged also D1764 into this to allow testing in one go.

aacid added a comment.Jun 7 2016, 11:48 AM

Honestly i don't have time to test this patch this week, but it looks reasonable (with the exception of my comments on D1764 ) so if you have tested it and works, i don't see any reason you should hold up commiting this

nienhueser accepted this revision.Jun 7 2016, 6:45 PM
nienhueser edited edge metadata.

Looks good to me.

This revision is now accepted and ready to land.Jun 7 2016, 6:45 PM

@aacid & @nienhueser Thanks for having had a look, will commit tomorrow then.

Hi Friedrich,

Thanks for your effort!

I applied this patch on top of branch Applications/16.04, but somehow it did not make the tr() translations work. I didn't run arc patch D1764 because arc patch D1763 already added the code from that review request.

What I did:
0. (I did _not_ create the en/.../marble_qt.qm translation file.)

  1. Generated the new marble_qt.ts for Russian language: "<TS version="2.1" language="ru">". It contains strings "Global Search" and "Distance:", as expected.
  2. Translated these two messages into Russian in this .ts file.
  3. Run lrelease marble_qt.ts to create marble_qt.qm.
  4. cp marble_qt.qm ~/.local/share/locale/ru/LC_MESSAGES/marble_qt.qm
  5. Run "strace marble".

I see Marble try to open en/LC_MESSAGES/marble_qt.qm, then successfully open ~/.local/share/locale/ru/LC_MESSAGES/marble_qt.qm, but "Global Search" and "Distance:" are both still in English in the UI.

Hi Alexander,

not idea why things do not work for you yet, I am only learning my way here as well. All I can tell is that trying to simulate the KDE translation process the following way seems to work for me, I get my custom German translations:

PATH=$HOME/Kode/kdesvn/trunk/l10n-kf5/scripts/:$PATH bash ~/Kode/kdesvn/trunk/l10n-kf5/scripts/extract-messages.sh
cp po/marble_qt.pot po/de/marble_qt.po
# here change some strings with lokalize in po/de/marble_qt.po, then...
lconvert-qt5 -i po/de/marble_qt.po -o po/de/marble_qt.ts -target-language de
lrelease-qt5 -removeidentical -silent po/de/marble_qt.ts -qm po/de/marble_qt.qm
sudo cp po/de/marble_qt.qm /usr/share/locale/de/LC_MESSAGES/marble_qt.qm
marble # with this patch in

(which BTW also hints that Marble still is missing respective things in its build system to have the qm file creation done at release time, but one step after the other).

This revision was automatically updated to reflect the committed changes.