Hi, On 11/09/14 16:59, service wrote: > Hi, I got a problem about internationalization on Sailfish, I want to > add Chinese language to my first Sailfish app, here is what I did > > 1. Add this on my .pro file > TRANSLATIONS += \ > translations/harbour-myappName-zh_CN.ts > > 2.translate the harbour-myappName-zh_CN.ts file > > Then what I should do? > > Should I use the QTranslator to load the .qm file?
If you use standard app template (based on libsailfishapp), then it should load the translation automatically, based on your phone's locale: https://github.com/sailfish-sdk/libsailfishapp/blob/master/src/sailfishapp_priv.cpp#L110 If not, you have to load and install the translation yourself. In my app, I do it like this (however, I ship translations in resources, thus ":/l10n" path): > const QString lc = QLocale().name(); > // Load Qt's translation > QTranslator qtTr; > if (qtTr.load("qt_" + lc, > QLibraryInfo::location(QLibraryInfo::TranslationsPath))) > app->installTranslator(&qtTr); > // Load TAOT's translation > QTranslator tr; > if (tr.load("taot_" + lc, ":/l10n")) > app->installTranslator(&tr); I also try to load Qt translation file, else all strings that come from Qt will remain in English. -- With best regards, Oleksii Serdiuk
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org