Internationalization Problem

Ralf Funken rfunken at kdevelop.de
Tue Mar 7 07:01:41 UTC 2000


Hi, 

there are some problems with internationalization with certain constructs. The
following code is an example for this:

Given :
------------------------------------------
if (file_info.lastModified() != actual_info->last_modified)
{
    qYesNo=QMessageBox::warning(this,i18n("..."),
    QString().sprintf(i18n("..."),actual_info->filename.data()),
    QMessageBox::Yes,QMessageBox::No); 
}

if (qYesNo==QMessageBox::Yes) 
------------------------------------------
you cannot localize the buttons.

To make this work I have to change the code to :
------------------------------------------
if (file_info.lastModified() != actual_info->last_modified)
{
    qYesNo=QMessageBox::warning(this,i18n("..."),
    QString().sprintf(i18n("..."),actual_info->filename.data()),
    i18n("&Yes"),i18n("&No")); 
}

if (qYesNo==0) // Yes button has been pressed
------------------------------------------

Besides there's always the danger of making mistakes when you change that and
the MessageBox is part of an 'if' clause or more generally if you use the
return code , because in the first example the return code is 3 for the 'yes'
Button, the second gives you 0. 

I'm asking you to use the second construct in the future as this will make
things easier. Another possibility if you really have to use the first one,
would be to set the text for the buttons explicitly, so it will appear in the
messages. 

Regards,

Ralf

-- 
Ralf Funken
rfunken at kdevelop.de
the kdevelop team    http://www.kdevelop.org





More information about the KDevelop-devel mailing list