[Qt-interest] Qt localization: loading the localizaed string probelm

Ramesh ramesh.bs at robosoftin.com
Tue Aug 10 13:01:33 CEST 2010


As u said dbzhang,

QT_TR_NOOP("hellow"); works only if the string is present in a function,
whose base class is Qobject.
But  I want to access the string declared in the global space..
So I have to use QT_TRANSLATE_NOOP, no option..

If I write QT_TR_NOOP("hellow");in global space Qt linguist tool doesn’t
recognize at all..:(



-----Original Message-----
From: 1+1=2 [mailto:dbzhang800 at gmail.com]
Sent: Tuesday, August 10, 2010 4:18 PM
To: Ramesh
Subject: Re: [Qt-interest] Qt localization: loading the localizaed string
probelm

On Tue, Aug 10, 2010 at 3:08 PM, Ramesh <ramesh.bs at robosoftin.com> wrote:
> Hi,
>
> i want to load the localized string in Qt application. for this i am
> following few steps, correct me if i am wrong.
>
> Note: it works fine for QString but not for const char*
>
> 1)update the pro file with translation language
>
> 2)generate .ts & edit using Qt linguist. Generate .qm file using lupdate
and
> lrelease.
>
> 3)load the .qm file from particular location.
>
> here is how my const char* looks.
>
> const char* sayHellow =
 QT_TRANSLATE_NOOP("FriendlyConversation","hellow");
you can try:
const char* sayHellow =  QT_TRANSLATE_NOOP("LocalizationWithQT","hellow");

or:

const char* sayHellow =  QT_TR_NOOP("hellow");

Debao
>
> LocalizationWithQT::LocalizationWithQT(QWidget *parent)
>     : QMainWindow(parent)
> {
>  //ui.setupUi(this);
>  QString str = tr("say hellow");
>  QPushButton *pushbutton = new QPushButton(tr(sayHellow));
>  setCentralWidget(pushbutton);
>
> }
>
> here how i am loading the .qm file
>
> QApplication a(argc, argv);
>
>     QTranslator translator;
>     bool val = translator.load("c:\\Data\\test\\hellotr_la");
>     a.installTranslator(&translator);
>
>     LocalizationWithQT w;
>     w.showMaximized();
>     return a.exec();
>
> the problem is, if i provide any alternate Latin string to "sayhellow" its
> not loading at all.. i don't nowhere is the mistake.. please suggest me
the
> solution..
>
> Thanks in advance
>
>
>
> -----------------------------------------------
>
> Robosoft Technologies - Come home to Technology
>
> Disclaimer: This email may contain confidential material. If you were not
an
> intended recipient, please notify the sender and delete all copies. Emails
> to and from our network may be logged and monitored. This email and its
> attachments are scanned for virus by our scanners and are believed to be
> safe. However, no warranty is given that this email is free of malicious
> content or virus.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list