<div dir="ltr"><div><div><div><div>Hi,<br><br></div>I added localization to my sailfishos app, as I didn't see a real example here I thought I'd post one for the sake of archiving (and googling).<br><br></div>The way it works is that I install qm files to /usr/share/$NAME/localization the qm files are of the form <2 letter language code>.qm, you could be more precise and produce e.g fr_FR.qm files (see <a href="http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html#load">http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html#load</a>). Here is the relevant main function :<br>
<br>int main(int argc, char *argv[])<br>{<br>    QGuiApplication* app =  SailfishApp::application(argc, argv);<br>    QString locale = QLocale::system().name();<br><br>    QTranslator translator;<br>    translator.load(locale,SailfishApp::pathTo(QString("localization")).toLocalFile());<br>
    app->installTranslator(&translator);<br>    return SailfishApp::main(argc, argv);<br>}<br><br></div><div>And relevant parts in my .pro<br><br>localization.files = localization<br>localization.path = /usr/share/$${TARGET}<br>
<br>INSTALLS += localization<br><br>lupdate_only {<br>    SOURCES = qml/*.qml \<br>                qml/pages/*.qml<br>    TRANSLATIONS = localization/fr.ts \<br>                    localization/en.ts<br>}<br></div><div><br>
</div>I think this could be integrated into libsailfishapp with lrelease being integrated in the build process, it would then only be a matter of running lupdate and making the translations, the rest would be automatic.<br>
<br></div>Antoine<br></div>