I have a small app that uses a Qt Quick MessageDialog
. I created translations files with command
lupdate-qt5 ../myapp.pro .
In myapp.pro I indicated:
lupdate_only {
SOURCES += $$PWD/ui/*.qml
}
and
TRANSLATIONS += \
translations/i18n_nl.ts translations/i18n_fr.ts translations/i18n_en.ts
All translations are generated correctly. But I have no idea how to generate translations for the standard buttons that MessageDialog
provides. In the following example the translations for "Warning" and "Please select Yes or No" are generated. But I can't get them generated for "Yes" and "No" (which is the text value of the StandardButtons
property)
MessageDialog {
title: qsTr("Warning")
text: qsTr("Please select Yes or No")
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No
//.....
}
I have checked the source code and it indicates that they should be translated:
Button {
id: yesButton
text: qsTr("Yes")
onClicked: root.click(StandardButton.Yes)
visible: root.standardButtons & StandardButton.Yes
}
I've also tried manually adding an entry Yes
and No
but that doesn't seem to help.
I've found an issue on stackoverflow that talks about adding the qml file to the .pro
file to make it work, and that is something I already do. I though about adding the built-in MessageDialog
, but I have no idea how to do this.
As a final note: I know that in Qt 5.3 the qsTr
's weren't in MessageDialog
. But starting from Qt 5.4 they are. I am currently on Qt 5.5
Any help is greatly appreciated.
EDIT
After posting this I kept looking and found an interesting post of someone who has had the same issue. Unfortunately, no answer there.
EDIT 2
Thank you tynn for the response. I have tried both suggestions but no succes. I did try something else as well. I added a qDebug in my code to see if it would translate. I was hoping the same translation would then be used for the MessageDialog
, but unfortunatly that doesn't seem to be the case.
qDebug() << "Translate yes :" << tr("Yes"); //translates correctly, dialog doesn't
I have also tried to build a dialog from scratch that does the same as the built-in messagedialog, but at the moment my knowledge of qml is too limited to get this working.