Skip to content

Commit

Permalink
BUG: Mark translatable strings in Base/QTCore
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdiop authored and lassoan committed Jan 22, 2023
1 parent 8989591 commit 1031050
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 76 deletions.
6 changes: 4 additions & 2 deletions Base/QTCore/qSlicerAbstractCoreModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ QString qSlicerAbstractCoreModule::defaultDocumentationLink()const
return "";
}
QString url = app->moduleDocumentationUrl(this->name());
QString linkText = QString("<p>For more information see the <a href=\"%1\">online documentation</a>.</p>").arg(url);
return linkText;
QString linkText = QString("<p>")
+ tr("For more information see the %1.").arg(
QString("<a href=\"%1\">%2</a>").arg(url).arg(tr("online documentation")))
+ QString("</p>");
}
38 changes: 21 additions & 17 deletions Base/QTCore/qSlicerCoreApplication.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ void qSlicerCoreApplicationPrivate::init()
// allow a debugger to be attached during startup
if(qApp->arguments().contains("--attach-process"))
{
QString msg("This message box is here to give you time to attach "
// Message for developers - do not translate.
QString msg(/*no tr*/"This message box is here to give you time to attach "
"your debugger to process [PID %1]");
QMessageBox::information(nullptr, "Attach process", msg.arg(QCoreApplication::applicationPid()));
QMessageBox::information(nullptr, /*no tr*/"Attach process", msg.arg(QCoreApplication::applicationPid()));
}

QCoreApplication::setOrganizationDomain(Slicer_ORGANIZATION_DOMAIN);
Expand Down Expand Up @@ -1299,7 +1300,7 @@ void qSlicerCoreApplication::setMRMLScene(vtkMRMLScene* newMRMLScene)

// First scene needs a crosshair to be added manually
vtkNew<vtkMRMLCrosshairNode> crosshair;
crosshair->SetCrosshairName("default");
crosshair->SetCrosshairName(/*no tr*/"default");
newMRMLScene->AddNode(crosshair.GetPointer());
}

Expand Down Expand Up @@ -1732,8 +1733,8 @@ int qSlicerCoreApplication::mainApplicationPatchVersion()const
QString qSlicerCoreApplication::libraries()const
{
QString librariesText(
"Built on top of: "
"<a href=\"https://www.vtk.org/\">VTK</a>, "
tr("Built on top of:") +
" <a href=\"https://www.vtk.org/\">VTK</a>, "
"<a href=\"https://www.itk.org/\">ITK</a>, "
"<a href=\"https://www.commontk.org/index.php/Main_Page\">CTK</a>, "
"<a href=\"https://www.qt.io/\">Qt</a>, "
Expand All @@ -1746,26 +1747,29 @@ QString qSlicerCoreApplication::libraries()const
//-----------------------------------------------------------------------------
QString qSlicerCoreApplication::copyrights()const
{
QString copyrightsText(
QString copyrightsText(QString(
"<table align=\"center\" border=\"0\" width=\"80%\"><tr>"
"<td align=\"center\"><a href=\"https://slicer.readthedocs.io/en/latest/user_guide/about.html#license\">Licensing Information</a></td>"
"<td align=\"center\"><a href=\"https://slicer.org/\">Website</a></td>"
"<td align=\"center\"><a href=\"https://slicer.readthedocs.io/en/latest/user_guide/about.html#acknowledgments\">Acknowledgments</a></td>"
"</tr></table>");
"<td align=\"center\"><a href=\"https://slicer.readthedocs.io/en/latest/user_guide/about.html#license\">%1</a></td>"
"<td align=\"center\"><a href=\"https://slicer.org/\">%2</a></td>"
"<td align=\"center\"><a href=\"https://slicer.readthedocs.io/en/latest/user_guide/about.html#acknowledgments\">%3</a></td>"
"</tr></table>")
.arg(tr("Licensing Information"))
.arg(tr("Website"))
.arg(tr("Acknowledgments")));
return copyrightsText;
}
//-----------------------------------------------------------------------------
QString qSlicerCoreApplication::acknowledgment()const
{
QString acknowledgmentText(
"Slicer is NOT an FDA approved medical device.<br /><br />"
"Supported by: NA-MIC, NAC, BIRN, NCIGT and the Slicer Community.<br /><br />"
"Special thanks to the NIH and our other supporters.<br /><br />"
tr("Slicer is NOT an FDA approved medical device.<br><br>"
"Supported by: NA-MIC, NAC, BIRN, NCIGT and the Slicer Community.<br><br>"
"Special thanks to the NIH and our other supporters.<br><br>"
"This work is part of the National Alliance for Medical Image Computing "
"(NA-MIC), funded by the National Institutes of Health through the NIH "
"Roadmap for Medical Research, Grant U54 EB005149. Information on the "
"National Centers for Biomedical Computing can be obtained from "
"<a href=\"https://commonfund.nih.gov/bioinformatics\">https://commonfund.nih.gov/bioinformatics</a>.<br /><br />");
"National Centers for Biomedical Computing can be obtained from"
"<a href=\"https://commonfund.nih.gov/bioinformatics\">https://commonfund.nih.gov/bioinformatics</a>.<br><br>"));
return acknowledgmentText;
}

Expand Down Expand Up @@ -2246,8 +2250,8 @@ QString qSlicerCoreApplication::documentationBaseUrl() const
// --------------------------------------------------------------------------
QString qSlicerCoreApplication::documentationVersion() const
{
QString version = "latest";
if (this->releaseType() == "Stable")
QString version = /*no tr*/"latest";
if (this->releaseType() == /*no tr*/"Stable")
{
version = QString("v%1.%2").arg(this->mainApplicationMajorVersion()).arg(this->mainApplicationMinorVersion());
}
Expand Down
78 changes: 39 additions & 39 deletions Base/QTCore/qSlicerCoreCommandOptions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool qSlicerCoreCommandOptions::parse(const QStringList& arguments)
bool qSlicerCoreCommandOptions::displayHelpAndExit()const
{
Q_D(const qSlicerCoreCommandOptions);
return d->ParsedArgs.value("help").toBool();
return d->ParsedArgs.value(/*no tr*/"help").toBool();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -251,7 +251,7 @@ CTK_SET_CPP(qSlicerCoreCommandOptions, bool, setRunPythonAndExit, RunPythonAndEx
bool qSlicerCoreCommandOptions::displayVersionAndExit() const
{
Q_D(const qSlicerCoreCommandOptions);
return d->ParsedArgs.value("version").toBool();
return d->ParsedArgs.value(/*no tr*/"version").toBool();
}

//-----------------------------------------------------------------------------
Expand All @@ -265,7 +265,7 @@ bool qSlicerCoreCommandOptions::displayProgramPathAndExit() const
bool qSlicerCoreCommandOptions::displayHomePathAndExit() const
{
Q_D(const qSlicerCoreCommandOptions);
return d->ParsedArgs.value("home").toBool();
return d->ParsedArgs.value(/*no tr*/"home").toBool();
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -351,7 +351,7 @@ bool qSlicerCoreCommandOptions::keepTemporarySettings() const
bool qSlicerCoreCommandOptions::isTestingEnabled() const
{
Q_D(const qSlicerCoreCommandOptions);
return d->ParsedArgs.value("testing").toBool();
return d->ParsedArgs.value(/*no tr*/"testing").toBool();
}

#ifdef Slicer_USE_PYTHONQT
Expand All @@ -367,109 +367,109 @@ bool qSlicerCoreCommandOptions::isPythonDisabled() const
void qSlicerCoreCommandOptions::addArguments()
{
this->addArgument("ignore-rest", "-", QVariant::Bool,
"Ignores the rest of the labeled arguments following this flag.",
/*no tr*/"Ignores the rest of the labeled arguments following this flag.",
QVariant(false), true);

this->addArgument("help", "h", QVariant::Bool,
"Display available command line arguments.");
this->addArgument(/*no tr*/"help", "h", QVariant::Bool,
/*no tr*/"Display available command line arguments.");

#ifdef Slicer_USE_PYTHONQT
QString testingDescription = "Activate testing mode. It implies --disable-settings and --ignore-slicerrc.";
QString testingDescription = /*no tr*/"Activate testing mode. It implies --disable-settings and --ignore-slicerrc.";
#else
QString testingDescription = "Activate testing mode. It implies --disable-settings.";
QString testingDescription = /*no tr*/"Activate testing mode. It implies --disable-settings.";
#endif
this->addArgument("testing", "", QVariant::Bool,
this->addArgument(/*no tr*/"testing", "", QVariant::Bool,
testingDescription,
QVariant(false));

#ifdef Slicer_USE_PYTHONQT
this->addArgument("disable-python", "", QVariant::Bool,
"Disable python support. This is equivalent to build the application with Slicer_USE_PYTHONQT=OFF.");
/*no tr*/"Disable python support. This is equivalent to build the application with Slicer_USE_PYTHONQT=OFF.");

this->addArgument("python-script", "", QVariant::String,
"Python script to execute after slicer loads.");
/*no tr*/"Python script to execute after slicer loads.");

this->addArgument("python-code", "", QVariant::String,
"Python code to execute after slicer loads.");
/*no tr*/"Python code to execute after slicer loads.");

this->addArgument("", "c", QVariant::String,
"Python code to execute after slicer loads. By default, no modules are loaded and Slicer exits afterward.");
/*no tr*/"Python code to execute after slicer loads. By default, no modules are loaded and Slicer exits afterward.");

this->addArgument("ignore-slicerrc", "", QVariant::Bool,
"Do not load the Slicer resource file (~/.slicerrc.py).");
/*no tr*/"Do not load the Slicer resource file (~/.slicerrc.py).");
#endif

this->addArgument("additional-module-path", "", QVariant::String,
"Additional module path to consider when searching for modules to load.");
/*no tr*/"Additional module path to consider when searching for modules to load.");

this->addArgument("additional-module-paths", "", QVariant::StringList,
"List of additional module path to consider when searching for modules to load.");
/*no tr*/"List of additional module path to consider when searching for modules to load.");

this->addArgument("modules-to-ignore", "", QVariant::String,
"Comma separated list of modules that should *NOT* be loaded.");
/*no tr*/"Comma separated list of modules that should *NOT* be loaded.");

this->addArgument("disable-modules", "", QVariant::Bool,
"Disable the loading of any Modules.");
/*no tr*/"Disable the loading of any Modules.");

this->addArgument("disable-builtin-modules", "", QVariant::Bool,
"Disable the loading of builtin Modules.");
/*no tr*/"Disable the loading of builtin Modules.");

#ifdef Slicer_BUILD_CLI_SUPPORT
this->addArgument("disable-cli-modules", "", QVariant::Bool,
"Disable the loading of any Command Line Modules.");
/*no tr*/"Disable the loading of any Command Line Modules.");

this->addArgument("disable-builtin-cli-modules", "", QVariant::Bool,
"Disable the loading of builtin Command Line Modules.");
/*no tr*/"Disable the loading of builtin Command Line Modules.");
#endif

this->addArgument("disable-loadable-modules", "", QVariant::Bool,
"Disable the loading of any Loadable Modules.");
/*no tr*/"Disable the loading of any Loadable Modules.");

this->addArgument("disable-builtin-loadable-modules", "", QVariant::Bool,
"Disable the loading of builtin Loadable Modules.");
/*no tr*/"Disable the loading of builtin Loadable Modules.");

#ifdef Slicer_USE_PYTHONQT
this->addArgument("disable-scripted-loadable-modules", "", QVariant::Bool,
"Disable the loading of any Scripted Loadable Modules.");
/*no tr*/"Disable the loading of any Scripted Loadable Modules.");

this->addArgument("disable-builtin-scripted-loadable-modules", "", QVariant::Bool,
"Disable the loading of builtinScripted Loadable Modules.");
/*no tr*/"Disable the loading of builtinScripted Loadable Modules.");
#endif

this->addArgument("version", "", QVariant::Bool,
"Display version information and exits.");
this->addArgument(/*no tr*/"version", "", QVariant::Bool,
/*no tr*/"Display version information and exits.");

this->addArgument("program-path", "", QVariant::Bool,
"Display application program path and exits.");
/*no tr*/"Display application program path and exits.");

this->addArgument("home", "", QVariant::Bool,
"Display home path and exits.");
this->addArgument(/*no tr*/"home", "", QVariant::Bool,
/*no tr*/"Display home path and exits.");

this->addArgument("settings-path", "", QVariant::Bool,
"Display settings path and exits.");
/*no tr*/"Display settings path and exits.");

this->addArgument("temporary-path", "", QVariant::Bool,
"Display temporary path and exits.");
/*no tr*/"Display temporary path and exits.");

this->addArgument("application-information", "", QVariant::Bool,
"Display application information in the terminal.");
/*no tr*/"Display application information in the terminal.");

this->addArgument("verbose-module-discovery", "", QVariant::Bool,
"Enable verbose output during module discovery process.");
/*no tr*/"Enable verbose output during module discovery process.");

this->addArgument("disable-settings", "", QVariant::Bool,
"Start application ignoring user settings and using new temporary settings.");
/*no tr*/"Start application ignoring user settings and using new temporary settings.");

this->addArgument("keep-temporary-settings", "", QVariant::Bool,
"Indicate whether temporary settings should be maintained.");
/*no tr*/"Indicate whether temporary settings should be maintained.");

this->addArgument("disable-message-handlers", "", QVariant::Bool,
"Start application disabling the 'terminal' message handlers.");
/*no tr*/"Start application disabling the 'terminal' message handlers.");

#if defined (Q_OS_WIN32) && !defined (Slicer_BUILD_WIN32_CONSOLE)
#else
this->addArgument("disable-terminal-outputs", "", QVariant::Bool,
"Start application disabling stdout/stderr outputs and capturing outputs only using the error log.");
/*no tr*/"Start application disabling stdout/stderr outputs and capturing outputs only using the error log.");
#endif
}

Expand Down
5 changes: 3 additions & 2 deletions Base/QTCore/qSlicerCoreIOManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ bool qSlicerCoreIOManager::loadNodes(const qSlicerIO::IOFileType& fileType,
// If no readers were able to read and load the file(s), success will remain false
bool success = false;
int numberOfUserMessagesBefore = userMessages ? userMessages->GetNumberOfMessages() : 0;
QString userMessagePrefix = QString("Loading %1 - ").arg(parameters["fileName"].toString());
//: %1 is the filename
QString userMessagePrefix = tr("Loading %1").arg(parameters["fileName"].toString()) + " - ";

QStringList nodes;
foreach (qSlicerFileReader* reader, readers)
Expand Down Expand Up @@ -612,7 +613,7 @@ bool qSlicerCoreIOManager::loadNodes(const qSlicerIO::IOFileType& fileType,
if (!success && userMessages != nullptr && userMessages->GetNumberOfMessages() == numberOfUserMessagesBefore)
{
// Make sure that at least one message is logged if reading failed.
userMessages->AddMessage(vtkCommand::ErrorEvent, (QString(tr("%1 load failed.")).arg(userMessagePrefix)).toStdString());
userMessages->AddMessage(vtkCommand::ErrorEvent, (tr("%1 load failed.").arg(userMessagePrefix)).toStdString());
}

loadedFileParameters.insert("nodeIDs", nodes);
Expand Down
Loading

0 comments on commit 1031050

Please sign in to comment.