[SailfishDevel] QML translations don't work

Yann Büchau nobodyinperson at gmx.de
Thu Mar 8 18:21:46 UTC 2018



Hey everyone,
 
I am finally hopping into developing Python-based apps for Sailfish. I am pretty amazed how easy it is actually. Being not so much of a gui guy, I like to do everything from CLI and by hand, not clicking stuff together. I am also more familiar with autotools that the QT build system. As a start I used the python-sample project from github/sailfishos. What I managed to do so far (gitlab.com/nobodyinperson/harbour-sailcash) is autotooling the rpm packaging (also on GitLab CI) without any interaction with the IDE, automated deployment to the device/emulator via ssh for quick development and Python gettext translation. All of this works wonderfully, except for the QML translation. I peeked at github/otsaloma/pan-transit and tried to replicate the folder structure, but the QML part just won't translate, no matter what translation function (qsTr, qsTrId, qsTranslate,QT_TR_NOOP [or whatever], etc...) I use. The Python part works flawlessly, similar to desktop apps or in general. However I noticed that when logged in via SSH, somehow none of the the LANG/locale environment variables are set which is a little annoying when starting the app from command line because no translation is performed. When launching the app from the grid, everything works.
 
Now my question is, what am I doing wrong so QML stuff won't translate? My QML is just the python-sample with some strings wrapped with qsTr(). Is the "translations" folder placed correctly?:
 
> rpm -ql harbour-sailcash
/usr/share/applications/harbour-sailcash.desktop
/usr/share/harbour-sailcash/locale/de/LC_MESSAGES/harbour-sailcash.mo
/usr/share/harbour-sailcash/locale/fr/LC_MESSAGES/harbour-sailcash.mo
/usr/share/harbour-sailcash/qml/cover/CoverPage.qml
/usr/share/harbour-sailcash/qml/cover/coveractions.py
/usr/share/harbour-sailcash/qml/harbour-sailcash.qml
/usr/share/harbour-sailcash/qml/pages/FirstPage.qml
/usr/share/harbour-sailcash/qml/pages/datadownloader.py
/usr/share/harbour-sailcash/translations/harbour-sailcash-de.qm
/usr/share/harbour-sailcash/translations/harbour-sailcash-fr.qm
/usr/share/icons/hicolor/108x108/apps/harbour-sailcash.png
/usr/share/icons/hicolor/128x128/apps/harbour-sailcash.png
/usr/share/icons/hicolor/256x256/apps/harbour-sailcash.png
/usr/share/icons/hicolor/86x86/apps/harbour-sailcash.png
/usr/share/icons/hicolor/scalable/apps/harbour-sailcash.svg
 
Is there anything I need to do in the QML to let it find the *.qm files?
 
Regards,
 
Yann


More information about the Devel mailing list