Re: [SailfishDevel] QML translations don't work
Hey Osmo, Thanks very much for the hint with the context. I was not using lupdate/lconvert because I don't like the dependency on QT for the build environment. I used xgettext but did not handle the context. I am now using qsTranslate, specifying the context explicitly and telling xgettext with the option -kqsTranslate:1c,2 to include the context. Now everything works. Thank you!!! Cheers, Yann On 08.03.2018 21:50, Osmo Salomaa wrote: On Thu, Mar 8, 2018, at 20:21, Yann Büchau wrote: 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(). What's your translation call like? Note that the context argument needs to match what is in the translation file. If you happened to copy the Pan Transit style of converting gettext po-files to Qt linguist files, then the context will be empty. I use the following helper function for QML translations: https://github.com/otsaloma/pan-transit/blob/master/qml/pan-transit.qml#L40 ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] QML translations don't work
Well, I am not familiar with Qt development in Python, but in C++ world, there is necessary to initialise translator before showing QML view... Try to look to these lines: https://github.com/Karry/osmscout-sailfish/blob/master/src/OSMScout.cpp#L147 // install translator QTranslator translator; QLocale locale; if (translator.load(locale.name(), SailfishApp::pathTo("translations").toLocalFile())) { qDebug() << "Install translator for locale " << locale << "/" << locale.name(); app->installTranslator(); }else{ qWarning() << "Can't load translator for locale" << locale << "/" << locale.name() << "(" << SailfishApp::pathTo("translations").toLocalFile() << ")"; } Lukas Dne čtvrtek 8. března 2018 22:14:48 CET Boris Pohler napsal(a): > That's how it works with my program. > > Just to be on the safe side, are the translation files in your rpm and in > /usr/share/harbour-sailcash/translations on the device? > > In your spec file in the given repo this information is missing in my > opinion, or am I missing something? > > Am Donnerstag, den 08.03.2018, 21:04 + schrieb Yann Büchau: > > Thanks Boris for the hint with setting the LANG variable. Although it > > should rather be LANG=de_DE.utf8 :-) Unfortunately, this still doesn't > > help with the QML translation problem. When I launch the app from the > > grid (which definitely has the locale set because the Python translation > > works), the QML ist not translated. Is it correct to have this?: > > > > Label { > > id: label > > anchors.centerIn: parent > > text: qsTr("Plain Cover") > > } > > > > If I run "strings" on the *.qm-files, both the translated and the original > > texts appear. I really don't get what I am doing wrong... I tried both > > creating the *.qm-files with msgfmt --qt and lconvert. No difference. > > > > Any clue? > > > > Regards, > > > > Yann > > > > Le Jeudi 8 mars 2018, Boris Pohler a écrit : > > > Sorry, should be > > > > > > export LANG=de > > > > > > Am Donnerstag, den 08.03.2018, 21:42 +0100 schrieb Boris Pohler: > > > > The behavior is normal and your directory structure is fine. > > > > > > > > If you log in via ssh and want to start the program, the language is > > > > not > > > > set: > > > > > > > > [nemo@Sailfish ~]$ locale > > > > LANG= > > > > LANGUAGE= > > > > LC_CTYPE="POSIX" > > > > LC_NUMERIC="POSIX" > > > > LC_TIME="POSIX" > > > > LC_COLLATE="POSIX" > > > > LC_MONETARY="POSIX" > > > > LC_MESSAGES="POSIX" > > > > LC_PAPER="POSIX" > > > > LC_NAME="POSIX" > > > > IC_ADDRESS="POSIX" > > > > IC_TELEPHONE="POSIX" > > > > LC_MEASUREMENT="POSIX" > > > > LC_IDENTIFICATION="POSIX" > > > > LC_ALL= > > > > > > > > Therefore, no language file can be loaded. For example, if you > > > > manually > > > > set > > > > the > > > > language with e. g. > > > > > > > > export LANG=en > > > > > > > > the German translation should be loaded afterwards. > > > > > > > > Grüße > > > > Boris > > > > > > > > Am Donnerstag, den 08.03.2018, 18:21 + schrieb Yann Büchau: > > > > > 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 > > > >
Re: [SailfishDevel] QML translations don't work
That's how it works with my program. Just to be on the safe side, are the translation files in your rpm and in /usr/share/harbour-sailcash/translations on the device? In your spec file in the given repo this information is missing in my opinion, or am I missing something? Am Donnerstag, den 08.03.2018, 21:04 + schrieb Yann Büchau: > Thanks Boris for the hint with setting the LANG variable. Although it should > rather be LANG=de_DE.utf8 :-) Unfortunately, this still doesn't help with the > QML translation problem. When I launch the app from the grid (which definitely > has the locale set because the Python translation works), the QML ist not > translated. Is it correct to have this?: > > Label { > id: label > anchors.centerIn: parent > text: qsTr("Plain Cover") > } > > If I run "strings" on the *.qm-files, both the translated and the original > texts appear. I really don't get what I am doing wrong... I tried both > creating the *.qm-files with msgfmt --qt and lconvert. No difference. > > Any clue? > > Regards, > > Yann > > Le Jeudi 8 mars 2018, Boris Pohler a écrit : > > Sorry, should be > > > > export LANG=de > > > > > > Am Donnerstag, den 08.03.2018, 21:42 +0100 schrieb Boris Pohler: > > > The behavior is normal and your directory structure is fine. > > > > > > If you log in via ssh and want to start the program, the language is not > > > set: > > > > > > [nemo@Sailfish ~]$ locale > > > LANG= > > > LANGUAGE= > > > LC_CTYPE="POSIX" > > > LC_NUMERIC="POSIX" > > > LC_TIME="POSIX" > > > LC_COLLATE="POSIX" > > > LC_MONETARY="POSIX" > > > LC_MESSAGES="POSIX" > > > LC_PAPER="POSIX" > > > LC_NAME="POSIX" > > > IC_ADDRESS="POSIX" > > > IC_TELEPHONE="POSIX" > > > LC_MEASUREMENT="POSIX" > > > LC_IDENTIFICATION="POSIX" > > > LC_ALL= > > > > > > Therefore, no language file can be loaded. For example, if you manually > > > set > > > the > > > language with e. g. > > > > > > export LANG=en > > > > > > the German translation should be loaded afterwards. > > > > > > Grüße > > > Boris > > > > > > > > > Am Donnerstag, den 08.03.2018, 18:21 + schrieb Yann Büchau: > > > > > > > > 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
Re: [SailfishDevel] QML translations don't work
Thanks Boris for the hint with setting the LANG variable. Although it should rather be LANG=de_DE.utf8 :-) Unfortunately, this still doesn't help with the QML translation problem. When I launch the app from the grid (which definitely has the locale set because the Python translation works), the QML ist not translated. Is it correct to have this?: Label { id: label anchors.centerIn: parent text: qsTr("Plain Cover") } If I run "strings" on the *.qm-files, both the translated and the original texts appear. I really don't get what I am doing wrong... I tried both creating the *.qm-files with msgfmt --qt and lconvert. No difference. Any clue? Regards, Yann Le Jeudi 8 mars 2018, Boris Pohler a écrit : > Sorry, should be > > export LANG=de > > > Am Donnerstag, den 08.03.2018, 21:42 +0100 schrieb Boris Pohler: > > The behavior is normal and your directory structure is fine. > > > > If you log in via ssh and want to start the program, the language is not > > set: > > > > [nemo@Sailfish ~]$ locale > > LANG= > > LANGUAGE= > > LC_CTYPE="POSIX" > > LC_NUMERIC="POSIX" > > LC_TIME="POSIX" > > LC_COLLATE="POSIX" > > LC_MONETARY="POSIX" > > LC_MESSAGES="POSIX" > > LC_PAPER="POSIX" > > LC_NAME="POSIX" > > IC_ADDRESS="POSIX" > > IC_TELEPHONE="POSIX" > > LC_MEASUREMENT="POSIX" > > LC_IDENTIFICATION="POSIX" > > LC_ALL= > > > > Therefore, no language file can be loaded. For example, if you manually set > > the > > language with e. g. > > > > export LANG=en > > > > the German translation should be loaded afterwards. > > > > Grüße > > Boris > > > > > > Am Donnerstag, den 08.03.2018, 18:21 + schrieb Yann Büchau: > > > > > > 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 > > > ___ > > > SailfishOS.org Devel mailing list > > > To unsubscribe, please send a mail to > > > devel-unsubscr...@lists.sailfishos.org > > > > ___ > > SailfishOS.org Devel mailing list > > To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org > -- > PGP Public Key: > http://pgp.mit.edu/pks/lookup?op=get=0xF5122BC2972E426 ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] QML translations don't work
Sorry, should be export LANG=de Am Donnerstag, den 08.03.2018, 21:42 +0100 schrieb Boris Pohler: > The behavior is normal and your directory structure is fine. > > If you log in via ssh and want to start the program, the language is not set: > > [nemo@Sailfish ~]$ locale > LANG= > LANGUAGE= > LC_CTYPE="POSIX" > LC_NUMERIC="POSIX" > LC_TIME="POSIX" > LC_COLLATE="POSIX" > LC_MONETARY="POSIX" > LC_MESSAGES="POSIX" > LC_PAPER="POSIX" > LC_NAME="POSIX" > IC_ADDRESS="POSIX" > IC_TELEPHONE="POSIX" > LC_MEASUREMENT="POSIX" > LC_IDENTIFICATION="POSIX" > LC_ALL= > > Therefore, no language file can be loaded. For example, if you manually set > the > language with e. g. > > export LANG=en > > the German translation should be loaded afterwards. > > Grüße > Boris > > > Am Donnerstag, den 08.03.2018, 18:21 + schrieb Yann Büchau: > > > > 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 > > ___ > > SailfishOS.org Devel mailing list > > To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org > > ___ > SailfishOS.org Devel mailing list > To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org -- PGP Public Key: http://pgp.mit.edu/pks/lookup?op=get=0xF5122BC2972E426D signature.asc Description: This is a digitally signed message part ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] QML translations don't work
The behavior is normal and your directory structure is fine. If you log in via ssh and want to start the program, the language is not set: [nemo@Sailfish ~]$ locale LANG= LANGUAGE= LC_CTYPE="POSIX" LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" LC_PAPER="POSIX" LC_NAME="POSIX" IC_ADDRESS="POSIX" IC_TELEPHONE="POSIX" LC_MEASUREMENT="POSIX" LC_IDENTIFICATION="POSIX" LC_ALL= Therefore, no language file can be loaded. For example, if you manually set the language with e. g. export LANG=en the German translation should be loaded afterwards. Grüße Boris Am Donnerstag, den 08.03.2018, 18:21 + schrieb Yann Büchau: > > 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 > ___ > SailfishOS.org Devel mailing list > To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org -- PGP Public Key: http://pgp.mit.edu/pks/lookup?op=get=0xF5122BC2972E426D signature.asc Description: This is a digitally signed message part ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org