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

Ramesh ramesh.bs at robosoftin.com
Tue Aug 10 14:57:05 CEST 2010


Hey, I have a last doubt..

If we have to use the same string In two different class, do we need to have
two copy of QT_TRANSLATE_NOOP or is there any solution for this?..


-----Original Message-----
From: Ramesh [mailto:ramesh.bs at robosoftin.com]
Sent: Tuesday, August 10, 2010 6:14 PM
To: '1+1=2'
Cc: 'qt-interest at trolltech.com'
Subject: RE: [Qt-interest] Qt localization: loading the localizaed string
probelm

Oh.. yeah.. u are amazing..
Finally it worked...

I didn’t understand my class name itself i.e LocalizationWithQT :(..

Ton's of thanks to you.. thanks lot...Thanks again..


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

My God, Please note what I had said !
> you can try:
> const char* sayHellow =  QT_TRANSLATE_NOOP("LocalizationWithQT","hellow");

the content is "LocalizationWithQT" which is your class name.



On Tue, Aug 10, 2010 at 8:20 PM, Ramesh <ramesh.bs at robosoftin.com> wrote:
> Ya, I do agree..
>
> As per this document http://web.mit.edu/qt/www/i18n.html
>
> Example of QT_TRANSLATE_NOOP():
>
>    static const char* greeting_strings[] = {
>        QT_TRANSLATE_NOOP( "FriendlyConversation", "Hello" ),
>        QT_TRANSLATE_NOOP( "FriendlyConversation", "Goodbye" )

"FriendlyConversation" is name of the class in which "tr(
greeting_strings[greet_type] )" was called
>    };
>
>    QString FriendlyConversation::greeting( int greet_type )
>    {
>        return tr( greeting_strings[greet_type] );
>    }
>
>    QString global_greeting( int greet_type )
>    {
>        return qApp->translate( "FriendlyConversation",
>                                greeting_strings[greet_type] );
>    }
>
>
> These are two way of getting localized string and Qt doc says both works
> fine..
> But for me The lateral way of getting the localizable string using
greeting(
> int greet_type ) doesn’t work but the former Method works fine i.e
> global_greeting function..
>
> So I have doubt in tr() and qApp->translate().. both are same or not?
> If so how?..
>
>
>
> -----Original Message-----
> From: 1+1=2 [mailto:dbzhang800 at gmail.com]
> Sent: Tuesday, August 10, 2010 5:38 PM
> To: Ramesh
> Subject: Re: [Qt-interest] Qt localization: loading the localizaed string
> probelm
>
> Please note that I said:
>> you can try:
>> const char* sayHellow =
 QT_TRANSLATE_NOOP("LocalizationWithQT","hellow");
>>
>> or:
> ...
>
> Maybe you need to read the manual:
>  QT_TRANSLATE_NOOP ( context, sourceText)
> in which context is important.
>
>
>
> On Tue, Aug 10, 2010 at 7:01 PM, Ramesh <ramesh.bs at robosoftin.com> wrote:
>> 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.
>>
>
>
> -----------------------------------------------
> 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.
>


-----------------------------------------------
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