Skip to content

Commit

Permalink
STYLE: Mark translatable strings in Base/QTGUI
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdiop committed Dec 19, 2022
1 parent 6c67bc6 commit a4cc0f2
Show file tree
Hide file tree
Showing 28 changed files with 154 additions and 146 deletions.
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerExportNodeDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ NodeTypeWidgetSet::NodeTypeWidgetSet(QWidget* parent, vtkMRMLStorableNode* stora
this->exportFormatComboBox->setCurrentIndex(-1);
this->exportFormatComboBox->setEditable(true); // so we can set custom text below
this->exportFormatComboBox->lineEdit()->setReadOnly(true);
this->exportFormatComboBox->setEditText("Select a format");
this->exportFormatComboBox->setEditText(qSlicerExportNodeDialog::tr("Select a format"));
}

// We make this connection now, not earlier, so that we don't trigger the signal with the above initialization.
Expand Down
12 changes: 6 additions & 6 deletions Base/QTGUI/qSlicerExtensionsLocalWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,17 @@ class qSlicerExtensionsDescriptionLabel : public QLabel
QString statusText;
if (!available && missing) // "missing" is checked so that we don't display this message when there have been no update checks before
{
statusText += QString("<p style=\"font-weight: bold; font-size: 80%; color: %1;\">"
"<img style=\"float: left\" src=\":/Icons/ExtensionIncompatible.svg\"/> "
"Not found for this version of the application (r%2)</p>")
statusText += QLatin1Literal("<p style=\"font-weight: bold; font-size: 80%; color: %1;\">"
"<img style=\"float: left\" src=\":/Icons/ExtensionIncompatible.svg\"/> ") +
qSlicerExtensionsLocalWidget::tr("Not found for this version of the application (r%2)") + QLatin1Literal("</p>")
.arg(this->WarningColor)
.arg(this->SlicerRevision);
}
if (!compatible)
{
statusText += QString("<p style=\"font-weight: bold; font-size: 80%; color: %1;\">"
"<img style=\"float: left\" src=\":/Icons/ExtensionIncompatible.svg\"/> "
"Incompatible with Slicer r%2 [built for r%3]</p>")
statusText += QLatin1Literal("<p style=\"font-weight: bold; font-size: 80%; color: %1;\">"
"<img style=\"float: left\" src=\":/Icons/ExtensionIncompatible.svg\"/> ") +
qSlicerExtensionsLocalWidget::tr("Incompatible with Slicer r%2 [built for r%3]") + QLatin1Literal("</p>")
.arg(this->WarningColor)
.arg(this->SlicerRevision)
.arg(this->WidgetItem->data(qSlicerExtensionsLocalWidgetPrivate::InstalledExtensionSlicerVersionRole).toString());
Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerExtensionsManagerDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void qSlicerExtensionsManagerDialogPrivate::init()
q, SLOT(onBatchProcessingChanged()));

QPushButton * restartButton = this->ButtonBox->button(QDialogButtonBox::Ok);
restartButton->setText("Restart");
restartButton->setText(qSlicerExtensionsManagerDialog::tr("Restart"));

q->setRestartRequested(false);

Expand Down
9 changes: 5 additions & 4 deletions Base/QTGUI/qSlicerExtensionsManagerWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ void qSlicerExtensionsManagerWidget::onModelUpdated()
}

d->tabWidget->setTabText(manageExtensionsTabIndex,
QString("Manage Extensions (%1)").arg(managedExtensionsCount));
//: %1 represents the number of managed extensions
tr("Manage Extensions (%1)").arg(managedExtensionsCount));

if (managedExtensionsCount == 0)
{
Expand Down Expand Up @@ -714,9 +715,9 @@ void qSlicerExtensionsManagerWidget::onInstallFromFileTriggered()
Q_D(qSlicerExtensionsManagerWidget);
const QStringList& archiveNames =
QFileDialog::getOpenFileNames(
this, "Select extension archive file(s)...", QString(),
"Archives (*.zip *.7z *.tar *.tar.gz *.tgz *.tar.bz2 *.tar.xz);;"
"All files (*)");
this, tr("Select extension archive file(s)..."), QString(),
tr("Archives") + " (*.zip *.7z *.tar *.tar.gz *.tgz *.tar.bz2 *.tar.xz);;" +
tr("All files") + " (*)");
if (archiveNames.empty())
{
return;
Expand Down
16 changes: 9 additions & 7 deletions Base/QTGUI/qSlicerExtensionsServerWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,29 @@ void qSlicerExtensionsServerWidgetPrivate::setFailurePage(const QStringList& err
"</style>"
"<div class='viewWrapperSlicer'>"
" <div class='extensionsHeader'>"
" <div class='extensionsTitle'>Slicer Extensions</div>"
" <div class='extensionsTitle'>" + qSlicerExtensionsServerWidget::tr("Slicer Extensions") + "</div>"
" </div>"
" <div class='extensionsBody'>"
" <!-- Following layout and associated CSS style are inspired from Mozilla error message. -->"
" <!-- It is originally covered by https://mozilla.org/MPL/2.0/ license -->"
" <!-- MPL 2.0 license is compatible with Slicer (BSD-like) license -->"
" <div class='error'>"
" <div id='errorTitle'><h1>Extensions can not be installed.</h1></div>"
" <div id='errorTitle'><h1>" + qSlicerExtensionsServerWidget::tr("Extensions can not be installed.") + "</h1></div>"
" <div id='errorDescription'>"
" <ul>"
"%1"
#ifdef Q_OS_MAC
" <li><b>Extensions manager requires <em>3D Slicer</em> to be installed. "
" <li><b>" + qSlicerExtensionsServerWidget::tr("Extensions manager requires <em>3D Slicer</em> to be installed. "
"Open the disk image (.dmg) file, drag <em>Slicer.app</em> into the the <em>Applications</em> folder, "
"and launch <em>3D Slicer</em> from the <em>Applications</em> folder.</b> "
"and launch <em>3D Slicer</em> from the <em>Applications</em> folder.") + "</b> "
#else
" <li>Check that <b>3D Slicer</b> is properly installed. "
" <li>" + qSlicerExtensionsServerWidget::tr("Check that <b>3D Slicer</b> is properly installed.") + " "
#endif
"<a href='https://slicer.readthedocs.io/en/latest/user_guide/getting_started.html#installing-3d-slicer'>Read more...</a></li>"
"<a href='https://slicer.readthedocs.io/en/latest/user_guide/getting_started.html#installing-3d-slicer'>" +
qSlicerExtensionsServerWidget::tr("Read more...") + "</a></li>"
" </ul>"
" <button id='errorTryAgain' onclick='window.extensions_install_widget.refresh();' autofocus='true'>Try Again</button>"
" <button id='errorTryAgain' onclick='window.extensions_install_widget.refresh();' autofocus='true'>" +
qSlicerExtensionsServerWidget::tr("Try Again") + "</button>"
" </div>"
" </div>"
" </div>"
Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerFileDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ QStringList qSlicerFileDialog::nameFilters(qSlicerIO::IOFileType fileType)
extensions << ctk::nameFilterToExtensions(nameFilter);
}
}
filters.insert(0, QString("All (") + extensions.join(" ") + QString(")"));
filters.insert(0, tr("All") + " (" + extensions.join(" ") + ")");
return filters;
}

Expand Down
10 changes: 5 additions & 5 deletions Base/QTGUI/qSlicerIOManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ bool qSlicerIOManagerPrivate::startProgressDialog(int steps)
return false;
}
int max = (steps != 1 ? steps : 100);
this->ProgressDialog = new QProgressDialog("Loading file... ", "Cancel", 0, max);
this->ProgressDialog->setWindowTitle(QString("Loading ..."));
this->ProgressDialog = new QProgressDialog(qSlicerIOManager::tr("Loading file... "), qSlicerIOManager::tr("Cancel"), 0, max);
this->ProgressDialog->setWindowTitle(qSlicerIOManager::tr("Loading ..."));
if (steps == 1)
{
// We only support cancelling a load action if we can have control over it
Expand Down Expand Up @@ -177,10 +177,10 @@ createUniqueDialogName(qSlicerIO::IOFileType fileType,
{
QString objectName;

objectName += action == qSlicerFileDialog::Read ? "Add" : "Save";
objectName += action == qSlicerFileDialog::Read ?/*no tr*/"Add" : /*no tr*/"Save";
objectName += fileType;
objectName += ioProperties["multipleFiles"].toBool() ? "s" : "";
objectName += "Dialog";
objectName += /*no tr*/"Dialog";

return objectName;
}
Expand Down Expand Up @@ -437,7 +437,7 @@ bool qSlicerIOManager::loadNodes(const qSlicerIO::IOFileType& fileType,
SlicerRenderBlocker renderBlocker;
bool needStop = d->startProgressDialog(1);
d->ProgressDialog->setLabelText(
"Loading file " + parameters.value("fileName").toString() + " ...");
qSlicerIOManager::tr("Loading file ") + parameters.value("fileName").toString() + " ...");
if (needStop)
{
d->ProgressDialog->setValue(25);
Expand Down
4 changes: 2 additions & 2 deletions Base/QTGUI/qSlicerModelsDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void qSlicerModelsDialogPrivate::openAddModelFileDialog()
QStringList filters = qSlicerFileDialog::nameFilters(q->fileType());
// TODO add last open directory
this->SelectedFiles = QFileDialog::getOpenFileNames(
this, "Select Model file(s)", "", filters.join(", "));
this, qSlicerModelsDialog::tr("Select Model file(s)"), "", filters.join(", "));
if (this->SelectedFiles.count() < 1)
{
return;
Expand All @@ -75,7 +75,7 @@ void qSlicerModelsDialogPrivate::openAddModelDirectoryDialog()
Q_Q(qSlicerModelsDialog);
// TODO add last open directory.
QString modelDirectory = QFileDialog::getExistingDirectory(
this, "Select a Model directory", "", QFileDialog::ReadOnly);
this, qSlicerModelsDialog::tr("Select a Model directory"), "", QFileDialog::ReadOnly);
if (modelDirectory.isEmpty())
{
return;
Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerModuleFactoryFilterModel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void qSlicerModuleFactoryFilterModel::setShowModules(const QStringList& modules)
this->setFilterRole(Qt::UserRole);
if (d->HideAllWhenShowModulesIsEmpty && modules.isEmpty())
{
this->setFilterWildcard("hide all modules");
this->setFilterWildcard(/*no tr*/"hide all modules");
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions Base/QTGUI/qSlicerModuleFinderDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void qSlicerModuleFinderDialog::onSelectionChanged(const QItemSelection& selecte
}
filteredCategories << category;
}
html.append(QString("<p><b>Category:</b> %1</p>").arg(filteredCategories.join(", ")));
html.append(QString("<p><b>" + tr("Category:") + "</b> %1</p>").arg(filteredCategories.join(", ")));

// Help
QString help = module->helpText();
Expand Down Expand Up @@ -228,45 +228,45 @@ void qSlicerModuleFinderDialog::onSelectionChanged(const QItemSelection& selecte
if (!module->contributors().isEmpty())
{
QString contributors = module->contributors().join(", ");
QString contributorsText = QString("<p><b>Contributors:</b> ") + contributors + "</p>";
QString contributorsText = "<p><b>" + tr("Contributors:") + "</b> " + contributors + "</p>";
html.append(contributorsText);
}

// Internal name
if (module->name() != module->title())
{
html.append(QString("<p><b>Internal name:</b> %1</p>").arg(module->name()));
html.append(QString("<p><b>" + tr("Internal name:") + "</b> %1</p>").arg(module->name()));
}

// Type
QString type = QLatin1String("Core");
QString type = tr("Core");
// Use "inherits" instead of "qobject_cast" because "qSlicerBaseQTCLI" depends on "qSlicerQTGUI"
if (module->inherits("qSlicerScriptedLoadableModule"))
{
type = QLatin1String("Python Scripted Loadable");
type = tr("Python Scripted Loadable");
}
else if (module->inherits("qSlicerLoadableModule"))
{
type = QLatin1String("C++ Loadable");
type = tr("C++ Loadable");
}
else if (module->inherits("qSlicerCLIModule"))
{
type = QLatin1String("Command-Line Interface (CLI)");
type = tr("Command-Line Interface (CLI)");
}
if (module->isBuiltIn())
{
type += QLatin1String(", built-in");
type += ", " + tr("built-in");
}
html.append(QString("<p><b>Type:</b> %1</p>").arg(type));
html.append(QString("<p><b>" + tr("Type:") + "</b> %1</p>").arg(type));

// Dependencies
if (!module->dependencies().empty())
{
html.append(QString("<p><b>Require:</b> %1</p>").arg(module->dependencies().join(", ")));
html.append(QString("<p><b>" + tr("Require:") + "</b> %1</p>").arg(module->dependencies().join(", ")));
}

// Location
html.append(QString("<p><b>Location:</b> %1</p>").arg(module->path()));
html.append(QString("<p><b>" + tr("Location:") + "</b> %1</p>").arg(module->path()));

d->ModuleDescriptionBrowser->setHtml(html);
}
Expand All @@ -275,7 +275,7 @@ void qSlicerModuleFinderDialog::onSelectionChanged(const QItemSelection& selecte
d->ModuleDescriptionBrowser->clear();
if (!moduleName.isEmpty())
{
d->ModuleDescriptionBrowser->setText(QString("%1 module is not loaded").arg(moduleName));
d->ModuleDescriptionBrowser->setText(tr("%1 module is not loaded").arg(moduleName));
}
}

Expand Down
3 changes: 2 additions & 1 deletion Base/QTGUI/qSlicerModulePanel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ void qSlicerModulePanel::addModule(qSlicerAbstractCoreModule* module)
if (!module->contributors().isEmpty())
{
QString contributors = module->contributors().join(", ");
QString contributorsText = QString("<br/><u>Contributors:</u> <i>") + contributors + "</i><br/>";
QString contributorsText = QString("<br/><u>%1</u> <i>").arg(tr("Contributors:"));
contributorsText += contributors + "</i><br/>";
d->AcknowledgementLabel->append(contributorsText);
}

Expand Down
4 changes: 3 additions & 1 deletion Base/QTGUI/qSlicerModulesListView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ void qSlicerModulesListViewPrivate::updateItem(QStandardItem* item)
}
if (coreModule->dependencies().count() > 0)
{
tooltip += QString("<br><br>Requires: %1").arg(coreModule->dependencies().join(", "));
tooltip += QString("<br><br>%1 %2")
.arg(qSlicerModulesListView::tr("Requires:"))
.arg(coreModule->dependencies().join(", "));
}
item->setToolTip(tooltip);

Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerMouseModeToolBar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ void qSlicerMouseModeToolBarPrivate::updatePlaceWidget()
this->PlaceWidgetAction->setIcon(icon);
this->PlaceWidgetAction->setText(placeNodeIconName);
this->PlaceWidgetAction->setData(vtkMRMLInteractionNode::Place);
QString tooltip = QString("Place a control point");
QString tooltip = qSlicerMouseModeToolBar::tr("Place a control point");
this->PlaceWidgetAction->setToolTip(tooltip);
this->PlaceWidgetAction->setCheckable(true);

Expand Down
2 changes: 1 addition & 1 deletion Base/QTGUI/qSlicerNodeWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ vtkMRMLNode* qSlicerNodeWriter::getNodeByID(const char *id)const
{
vtkMRMLSceneViewNode *svNode = vtkMRMLSceneViewNode::SafeDownCast(*it);
// skip "Master Scene View" since it contains the same nodes as the scene
if (svNode->GetName() && std::string("Master Scene View") == std::string(svNode->GetName()))
if (svNode->GetName() && std::string(/*no tr*/"Master Scene View") == std::string(svNode->GetName()))
{
continue;
}
Expand Down
Loading

0 comments on commit a4cc0f2

Please sign in to comment.