Reply to topic

Using KDE4 translation mechanism in "pure" QT4 application

dentharg
Registered Member
Posts
7
Karma
0
OS
Hi!

I'm writing an application that is currently a pure QT4 app. It is designed to run cleanly on both Linux and Windows.

However I plan to integrate it a bit into KDE in future.

Here come the problems with localization/translations.

QT4 uses its own tr()/tr().arg().arg() mechanism and .ts/.qm files.
KDE4 uses gettext and i18n/p and .po files.

How, easily, can I use KDE4's mechanism in my QT4 application without having to closely integrate it with KDE now (apparently making it non-runnable on Windows)?

Thanks!


dentharg, proud to be a member of KDE forums since 2008-Oct.
User avatar Brandybuck
KDE Developer
Posts
203
Karma
0
OS
If the app is not a KDE app, then I would stick with the Qt mechanism (tr(), lupdate, etc). Replacing tr() with i18n() in the future is trivial. The largest amount of work is converting Qt .ts translations to gettext format, but that's something that's largely scriptable.

Standard disclaimers: IMHO, IANAL, YMMV, YADA YADA...


Don't look back! (Or you might see the giants whose shoulders we stand on)
dentharg
Registered Member
Posts
7
Karma
0
OS
I will go this way exactly :)

Especially that I have learned today that QT 4.5 preview already supports both .po and .xliff :D
Linguist has been thoroughly extended to support those 2 formats.


dentharg, proud to be a member of KDE forums since 2008-Oct.
User avatar anda_skoa
KDE Developer
Posts
783
Karma
4
OS
At some point you could consider shipping a KDE framework based on both platforms, i.e. always using KDE's superior localization framework.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar YeahReally
Registered Member
Posts
71
Karma
1
OS
A bit on topic: why KDE does not use Qt's translation mechanism?


Debian GNU/Linux Lenny
KDE 4.1.96

How many bugs have you triaged today?
User avatar bcooksley
Administrator
Posts
19763
Karma
87
OS
Because at the time the port to Qt4 which became KDE 4 was started, Qt did not support the method of Translation that KDE preferred. Apparently Qt4.5 is adding this, but due to the binary compatibility requirements of the KDE libraries, the current method will remain available until KDE 5.


KDE Sysadmin
[img]http://forum.kde.org/content/bcooksley_sig.png[/img]
User avatar anda_skoa
KDE Developer
Posts
783
Karma
4
OS
It is probably not only that.

KDE has a very sophisticated localization implementation, e.g. additional context, special markup for certain types of placeholders or variables.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar YeahReally
Registered Member
Posts
71
Karma
1
OS
bcooksley wrote:Because at the time the port to Qt4 which became KDE 4 was started, Qt did not support the method of Translation that KDE preferred. Apparently Qt4.5 is adding this, but due to the binary compatibility requirements of the KDE libraries, the current method will remain available until KDE 5.

I know that, and it has not been released yet. My question is: why is gettext prefered?
anda_skoa wrote:It is probably not only that.

KDE has a very sophisticated localization implementation, e.g. additional context, special markup for certain types of placeholders or variables.

Qt's is good as well (IMO better). What I dislike of gettext is that it is written for english speakers. An application has to be written in English or a very similar language.


Debian GNU/Linux Lenny
KDE 4.1.96

How many bugs have you triaged today?
User avatar anda_skoa
KDE Developer
Posts
783
Karma
4
OS
YeahReally wrote:Qt's is good as well (IMO better).


Ah, interesting. My understanding was that only KDE's system had semantic markup, etc. Other l10n system often just work with HTML like markup without taking into considerations that not all glyph system can apply them equally, e.g. "" is stupid for Asian languages, "" can be realized by using a different glyph.
See also http://techbase.kde.org/Development/Tut ... _Semantics

But nice to hear that Qt now has this as well.

YeahReally wrote:What I dislike of gettext is that it is written for english speakers. An application has to be written in English or a very similar language.


How does it bias for English? As far as I know English is only used because most translators can translate from English into their language.
Especially in community based translation teams.

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar ComaWhite
KDE Developer
Posts
100
Karma
0
OS
How are translations in KDE4 done? Is it like Qt4 where you use Linquist to do it?


Image
KDE Version: 4.6 (Beta 2) | Qt Version: 4.7.1
Aki IRC Developer http://www.akiirc.org/
User avatar YeahReally
Registered Member
Posts
71
Karma
1
OS
It is very similar to Linguist. You extract every translatable string with xgettext to a PO file. And then you translate to every target language in MO files.

anda_skoa wrote:How does it bias for English? As far as I know English is only used because most translators can translate from English into their language.
Especially in community based translation teams.


The way plurals are handledl.

I know English is a better base language for projects like KDE and GNU. But, for projects outside that or with very different targets, that is so not true.

The world would be a better place if everybody knew Spanish anyway[/jk]

[Edit] It seems to me that Linguist may not had been taken seriously earlier. A pity.

Last edited by YeahReally on Sun Jan 11, 2009 3:13 pm, edited 1 time in total.


Debian GNU/Linux Lenny
KDE 4.1.96

How many bugs have you triaged today?
User avatar Brandybuck
KDE Developer
Posts
203
Karma
0
OS
anda_skoa wrote:"" is stupid for Asian languages


True, but "bold" has not semantic meaning, it's a display tag. "strong" should be used instead. But regardless, the problem is solved if you translate the *tag*.


Don't look back! (Or you might see the giants whose shoulders we stand on)
User avatar torkiano
Registered Member
Posts
28
Karma
0
OS
ComaWhite wrote:How are translations in KDE4 done? Is it like Qt4 where you use Linquist to do it?


And the tool for translate .po files in KDE is Lokalize instead linguist


Kubuntu 9.04 (alpha5) i386 - KDE 4.2.1
User avatar anda_skoa
KDE Developer
Posts
783
Karma
4
OS
YeahReally wrote:
anda_skoa wrote:How does it bias for English? As far as I know English is only used because most translators can translate from English into their language.
Especially in community based translation teams.


The way plurals are handledl.


You mean that it offers facilities to have as many plural forms as necessary for the target language?

http://techbase.kde.org/Development/Tut ... 8n#Plurals

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
User avatar YeahReally
Registered Member
Posts
71
Karma
1
OS
Not the target language, the *coded* language (without translation). As you can see in that page, gettext requires two phrases in english plural style. That is what is English-like. And no, it does not fit most languages.


Debian GNU/Linux Lenny
KDE 4.1.96

How many bugs have you triaged today?

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], boudewijn, cairncrossr, chechoxque, Google [Bot], ipwizard, Stephen Leibowitz, Yahoo [Bot]