I'm displaying a simple Yes/No QMessageBox. This works fine in English. However, I want to internationalize this for French, so that it displays Oui/Non instead. Is there an easy way to change the text in the buttons for Yes/No?
I'm displaying a simple Yes/No QMessageBox. This works fine in English. However, I want to internationalize this for French, so that it displays Oui/Non instead. Is there an easy way to change the text in the buttons for Yes/No?
Software Engineer
There's no easy way, but a standard one: http://doc.trolltech.com/4.3/i18n.ht...e-translations
Hi,
Qt Code:
tr("My message translated"), this); //Set the translation text of the buttons. Here you need to have a QTranslator installed that will translate the "Yes" and "No" texts:To copy to clipboard, switch view to plain text mode
Òscar Llarch i Galán
gfunk (20th November 2007)
What version of Qt are you using?
This should work for 4.2.2 (it does for me):
Qt Code:
QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes"); QT_TRANSLATE_NOOP("QDialogButtonBox", "&No");To copy to clipboard, switch view to plain text mode
Check QDialogButtonBox.cpp for other strings to translate
gfunk (20th November 2007)
You should load a Qt library translator. There are some translators in %QTDIR%\translations which translate every user visible text in Qt library. French one is incomplete, but you may modify it in linguist.
Qt Code:
qtTranslator->load( ); appTranslator->load(...); // Load your translator installTranslator(appTranslator); installTranslator(qtTranslator);To copy to clipboard, switch view to plain text mode
Bookmarks