-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Fix lupdate warnings on translation function calls #1067
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just added a few minor comments.
Libs/Widgets/ctkSettingsDialog.cpp
Outdated
@@ -167,11 +167,11 @@ void ctkSettingsDialogPrivate::updateRestartRequiredLabel() | |||
bool restartRequired = !restartRequiredSettings.isEmpty(); | |||
if (restartRequired) | |||
{ | |||
QString header = q->tr( | |||
QString header = ctkSettingsDialog::tr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not too complicated, remove HTML tags from translatable text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, HTML tags are now separated from the translatable text.
1d02596
to
04c3dcc
Compare
04c3dcc
to
e83aa1e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, it all looks good except a trivial change (see inline).
Libs/Widgets/ctkSettingsDialog.cpp
Outdated
QString footer = q->tr("</small>"); | ||
QString header = "<b style=\"color:red\">" + ctkSettingsDialog::tr("Restart required!") + "</b><br>\n<small>"; | ||
header += ctkSettingsDialog::tr( | ||
"The application must be restarted to take into account the new values of the following properties:\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move out the \n
from the translatable string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's done now, thanks !
e83aa1e
to
dc6e488
Compare
QString header = "<b style=\"color:red\">" + ctkSettingsDialog::tr("Restart required!") + "</b><br><small>"; | ||
header += ctkSettingsDialog::tr( | ||
"The application must be restarted to take into account the new values of the following properties:" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need the \n
at the end of the header, I just asked for adding it outside the tr()
function.
Could you add "\n" to the header after the header += ctkSettingsDialog::tr("The application must be restarted...properties:");
line? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok I see, the update is done. Thanks.
Qt lupdate tool throws `Cannot invoke tr() like this` warnings when translation function is called using `q->tr(...)`. The problem is that lupdate cannot determine the class name `tr()` is called on and therefore it does not know the translation context. The solution is to spell out the class name in the call, for example `ctkSettingsDialog::tr(...)`. More details are described here: https://github.com/Slicer/SlicerLanguagePacks/blob/main/DevelopersManual.md see Slicer/SlicerLanguagePacks#17 see Slicer/SlicerLanguagePacks#12
dc6e488
to
37a6fbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, it looks good, ready to be merged!
Qt lupdate tool throws
Cannot invoke tr() like this
warnings when translation function is called usingq->tr(...)
. The problem is that lupdate cannot determine the class nametr()
is called on and therefore it does not know the translation context. The solution is to spell out the class name in the call, for exampleqSlicerScalarVolumeDisplayWidget::tr(...)
. More details are described here: https://github.com/Slicer/SlicerLanguagePacks/blob/main/DevelopersManual.mdsee Slicer/SlicerLanguagePacks#17
see Slicer/SlicerLanguagePacks#12