qt - Using KDE4 localization mechanisms in pure QT4 application - Stack Overflow

admin2023-02-27  580

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 and 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/i18np mechanism 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)?

Is it at all possible?

Thanks!

Answers:

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 and 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/i18np mechanism 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)?

Is it at all possible?

Thanks!

Answers:

Starting version 4.5, Qt will support both .po and .xliff;

http://doc.trolltech.com/4.5/qt4-5-intro.html#qt-linguist-improvements

Answers:

I think you will need to just pick one and go with it, if it is a cross platform app, I'd go with QT's method. The reason why is that KDE wraps it's internationalized string with i18*() macros and QT uses tr() macros, since a macro can't produce another macro, there is no way unless you have #ifdef's all over your code, or a massive string table...both of which suck.

转载请注明原文地址:https://www.jcdi.cn/read-201117.html
New Post(0)