Skip to content

Commit 2d09605

Browse files
u8621011jcfr
andcommitted
ENH: i18n: Associate CLI Module with translation context
Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
1 parent 1e2c14a commit 2d09605

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Base/QTCLI/qSlicerCLIModuleUIHelper.cxx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ QWidget* qSlicerCLIModuleUIHelperPrivate::createImageTagWidget(const ModuleParam
667667
QString imageLabel = QString::fromStdString(moduleParameter.GetLabel());
668668
QString imageName = QString::fromStdString(moduleParameter.GetName());
669669

670+
imageLabel = QCoreApplication::translate(
671+
this->CLIModuleWidget->moduleName().toLatin1(), imageLabel.toLatin1());
672+
670673
// If "type" is specified, only display nodes of type nodeType
671674
// (e.g. vtkMRMLScalarVolumeNode), don't display subclasses
672675
// (e.g. vtkMRMLDiffusionTensorVolumeNode)
@@ -1078,7 +1081,9 @@ QWidget* qSlicerCLIModuleUIHelper::createTagWidget(const ModuleParameter& module
10781081

10791082
if (widget)
10801083
{
1081-
QString description = QString::fromStdString(moduleParameter.GetDescription());
1084+
QString description = QCoreApplication::translate(
1085+
d->CLIModuleWidget->moduleName().toLatin1(), moduleParameter.GetDescription().c_str());
1086+
10821087
widget->setToolTip(description);
10831088
QString widgetName = QString::fromStdString(moduleParameter.GetName());
10841089
widget->setObjectName(widgetName);

Base/QTCLI/qSlicerCLIModuleWidget.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ void qSlicerCLIModuleWidgetPrivate::addParameter(QFormLayout* _layout,
289289
const ModuleParameter& moduleParameter)
290290
{
291291
Q_ASSERT(_layout);
292+
Q_Q(qSlicerCLIModuleWidget);
292293

293294
if (moduleParameter.GetHidden() == "true")
294295
{
@@ -298,6 +299,9 @@ void qSlicerCLIModuleWidgetPrivate::addParameter(QFormLayout* _layout,
298299
QString _label = QString::fromStdString(moduleParameter.GetLabel());
299300
QString description = QString::fromStdString(moduleParameter.GetDescription());
300301

302+
_label = QCoreApplication::translate(q->moduleName().toLatin1(), _label.toLatin1());
303+
description = QCoreApplication::translate(q->moduleName().toLatin1(), description.toLatin1());
304+
301305
// TODO Parameters with flags can support the None node because they are optional
302306
//int noneEnabled = 0;
303307
//if (moduleParameter.GetLongFlag() != "" || moduleParameter.GetFlag() != "")

0 commit comments

Comments
 (0)