Qt 5.9.0 QMessageBox Chinese translation
I've recently encountered several issues when trying to translate the QMessageBox::Yes, No, Close, Cancel and OK buttons into Chinese.
After a clean Qt 5.9.0 installation, when loading the translations/qt_zh_CN.qm file, all the mentioned buttons for a QMessageBox created object are not translated.
When running the windeployqt command, using therefore the generated qt_zh_CN.qm file, only the QMessageBox::Yes, No and Close buttons are translated. I understand that no translation texts are available for the Cancel and OK buttons.
Please let me know whether you identify any problems with the previously described behavior, or if I need to perform additional steps for a complete translation.
Thank you in advance!
Some standard components like the yes/no/ok/cancel are handled by the system rather than the application. That means that regardless of the translation file you load, they will use the system language to determine the content of the button.
If that is not something you can live with you can always create the message box with no standard buttons, and add the buttons manually:
QMessageBox msgBox; msgBox.addButton(new QPushButton(tr("Yes")),QMessageBox::YesRole); msgBox.addButton(new QPushButton(tr("No")),QMessageBox::NoRole);
I've got the same issue. When I use another translation, for example German, the buttons are translated.
See my topic here: