I have a small application that uses Qt Quick MessageDialog . I created translation files using the 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 do not know how to create translations for the standard buttons that MessageDialog provides. The following example creates translations for “Warning” and “Please select“ Yes ”or“ No. ”But I cannot get them generated for“ Yes ”or“ No ”(this 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 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 also tried manually adding the Yes and No entry, but this does not seem to help.
I found the problem https://stackoverflow.com/a/16626960/163848 which says about adding a qml file to the .pro file so that it works, and this is what I already do, I would like to add a built-in MessageDialog , but I have concepts don't have how to do this.
As a final note: I know that in Qt 5.3 qsTr were not in MessageDialog . But starting with Qt 5.4 they are. I'm on Qt 5.5 now
Any help is greatly appreciated.
EDIT
After posting this, I continued to search and found an interesting post of the one who had the same problem. Unfortunately, there is no answer.
EDIT 2
Thank you for the answer. I tried both sentences, but did not succeed. I also tried something else. I added qDebug to my code to see if it will translate. I was hoping the same translation would be used for MessageDialog , but unfortunately this is not the case.
qDebug() << "Translate yes :" << tr("Yes");
I also tried to create a dialogue from scratch that does the same as the built-in messagedialog, but currently my qml knowledge is too limited to make it work.