RE: [QtEI] Translation suggestion
Hello, in all the applications I write with Qt I'm using the tr() function. The advantage is, that it is much shorter to write (and therefore IMHO to read) and that QtLinguist is automatically showing the right context. QtLinguist organizes the strings that are translatable by context - typically the class names. When using tr() this is set automatically, when using qApp-translate() you have to (but also: can) set the context yourself. Another consideration is that tr() is only available in classes derived from QObject - but since normally the strings you want to translate are generated in Gui-classes this is normally the case. To sum up: Personally I prefer tr(), but it doesn't really matter what you use. Roland -Original Message- From: community-boun...@lists.openmoko.org [mailto:community- boun...@lists.openmoko.org] On Behalf Of Fabio Locati Sent: Thursday, April 30, 2009 6:41 AM To: List for Openmoko community discussion Subject: Re: [QtEI] Translation suggestion On the doc.trolltech.com, there isn't written that QApp-translate is better than tr, if I read correctly. http://doc.trolltech.com/4.5/qobject.html#tr http://doc.trolltech.com/4.5/qcoreapplication.html#translate Then is better leaving the tr() or switching to QApp-translate()? On Sun, Apr 26, 2009 at 11:33 PM, Franky Van Liedekerke liede...@telenet.be wrote: On Sun, 26 Apr 2009 23:14:05 +0200 Fabio Locati fabioloc...@gmail.com wrote: I have looked around and it seems that QtEI should be translated with Qt Linguistic. Is this the best tool? I don't know the tool, but I do believe there's much work to be done here: many classes still use tr while I believe every class should use qApp-translate for translations. Thoughts, suggestions? Franky ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community -- Fabio A Locati Home: Segrate, Milan, Italy (GMT +1) Phone: +39-328-3799681 MSN/Jabber/E-Mail: fabioloc...@gmail.com PGP Key: 9EF6 3C79 F6DF 76CD 770A 43A1 DCCB 415C 9656 3334 Envolved in: KDE, OpenStreetMap, Ubuntu, Wikimedia ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [QtEI] Translation suggestion
Another consideration is that tr() is only available in classes derived from QObject - but since normally the strings you want to translate are generated in Gui-classes this is normally the case. iirc tr is a static method of QObject, ie QObject::tr() should be possible regardless of inheritance. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
RE: [QtEI] Translation suggestion
Another consideration is that tr() is only available in classes derived from QObject - but since normally the strings you want to translate are generated in Gui-classes this is normally the case. iirc tr is a static method of QObject, ie QObject::tr() should be possible regardless of inheritance. Sorry. Of course you are correct. The disadvantage of using QObject::tr() compared to qApp-translate() (or to be more exact the static function QCoreApplication::translate()) is that you can not specify a context and that it is not set automatically if the class is not inheriting QObject. Roland ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [QtEI] Translation suggestion
The disadvantage of using QObject::tr() compared to qApp-translate() eh? from what you wrote earlier i got the impression it is exactly the other way round. ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
RE: [QtEI] Translation suggestion
The disadvantage of using QObject::tr() compared to qApp-translate() eh? from what you wrote earlier i got the impression it is exactly the other way round. You're right, kind of confusing. This is how I understood how it works: When using QCoreApplication::translate() you have to provide the context yourself. When using QObject::tr(), the context is generated automatically by Qt. From the documentation of Qt: All QObject subclasses using the Q_OBJECT macro automatically have a reimplementation of this function with the subclass name as context. Therefore I have to correct my earlier explanation a little bit: Inheriting from QObject is not sufficient, you must also supply the Q_OBJECT macro. When the macro is used in a class, Qt's moc (Meta-Object Compiler) generates more information for the class - including the translation-context. You can find more information about the meta-object system under http://doc.trolltech.com/qtextended4.4/metaobjects.html. I hope this didn't create more confusion... Roland ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [QtEI] Translation suggestion
On the doc.trolltech.com, there isn't written that QApp-translate is better than tr, if I read correctly. http://doc.trolltech.com/4.5/qobject.html#tr http://doc.trolltech.com/4.5/qcoreapplication.html#translate Then is better leaving the tr() or switching to QApp-translate()? On Sun, Apr 26, 2009 at 11:33 PM, Franky Van Liedekerke liede...@telenet.be wrote: On Sun, 26 Apr 2009 23:14:05 +0200 Fabio Locati fabioloc...@gmail.com wrote: I have looked around and it seems that QtEI should be translated with Qt Linguistic. Is this the best tool? I don't know the tool, but I do believe there's much work to be done here: many classes still use tr while I believe every class should use qApp-translate for translations. Thoughts, suggestions? Franky ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community -- Fabio A Locati Home: Segrate, Milan, Italy (GMT +1) Phone: +39-328-3799681 MSN/Jabber/E-Mail: fabioloc...@gmail.com PGP Key: 9EF6 3C79 F6DF 76CD 770A 43A1 DCCB 415C 9656 3334 Envolved in: KDE, OpenStreetMap, Ubuntu, Wikimedia ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
[QtEI] Translation suggestion
I have looked around and it seems that QtEI should be translated with Qt Linguistic. Is this the best tool? -- Fabio A Locati Home: Segrate, Milan, Italy (GMT +1) Phone: +39-328-3799681 MSN/Jabber/E-Mail: fabioloc...@gmail.com PGP Key: 9EF6 3C79 F6DF 76CD 770A 43A1 DCCB 415C 9656 3334 Envolved in: KDE, OpenStreetMap, Ubuntu, Wikimedia ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community
Re: [QtEI] Translation suggestion
On Sun, 26 Apr 2009 23:14:05 +0200 Fabio Locati fabioloc...@gmail.com wrote: I have looked around and it seems that QtEI should be translated with Qt Linguistic. Is this the best tool? I don't know the tool, but I do believe there's much work to be done here: many classes still use tr while I believe every class should use qApp-translate for translations. Thoughts, suggestions? Franky ___ Openmoko community mailing list community@lists.openmoko.org http://lists.openmoko.org/mailman/listinfo/community