[SailfishDevel] Internationalization problem on Sailfish
Oleksii Serdiuk
contacts at oleksii.name
Thu Sep 11 16:42:24 UTC 2014
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4813 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140911/e98ed195/attachment.bin>
More information about the Devel
mailing list