Skip to content

Commit

Permalink
BUG: Mark translatable strings in Base/QTCli
Browse files Browse the repository at this point in the history
Some user-visible strings were not marked as translatable.

see Slicer/SlicerLanguagePacks#12
  • Loading branch information
lassoan committed Feb 9, 2023
1 parent f555adc commit a0bd3f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
32 changes: 16 additions & 16 deletions Base/QTCLI/qSlicerCLIExecutableModuleFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ qSlicerAbstractCoreModule* qSlicerCLIExecutableModuleFactoryItem::instanciator()
if (python_path.isEmpty())
{
this->appendInstantiateErrorString(
QString("Failed to find python interpreter for CLI: %1").arg(this->path()));
qSlicerCLIModule::tr("Failed to find python interpreter for CLI: %1").arg(this->path()));
return nullptr;
}

Expand All @@ -110,8 +110,8 @@ qSlicerAbstractCoreModule* qSlicerCLIExecutableModuleFactoryItem::instanciator()
}
else
{
this->appendInstantiateErrorString(QString("CLI description: %1").arg(xmlFilePath));
this->appendInstantiateErrorString("Failed to read Xml Description");
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI description: %1").arg(xmlFilePath));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("Failed to read XML Description"));
}
}
else
Expand Down Expand Up @@ -148,35 +148,35 @@ QString qSlicerCLIExecutableModuleFactoryItem::runCLIWithXmlArgument()
bool res = cli.waitForFinished(cliProcessTimeoutInMs);
if (!res)
{
this->appendInstantiateErrorString(QString("CLI executable: %1").arg(this->path()));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI executable: %1").arg(this->path()));
QString errorString;
switch(cli.error())
{
case QProcess::FailedToStart:
errorString = QLatin1String(
errorString = qSlicerCLIModule::tr(
"The process failed to start. Either the invoked program is missing, or "
"you may have insufficient permissions to invoke the program.");
break;
case QProcess::Crashed:
errorString = QLatin1String(
errorString = qSlicerCLIModule::tr(
"The process crashed some time after starting successfully.");
break;
case QProcess::Timedout:
errorString = QString(
errorString = qSlicerCLIModule::tr(
"The process timed out after %1 msecs.").arg(cliProcessTimeoutInMs);
break;
case QProcess::WriteError:
errorString = QLatin1String(
errorString = qSlicerCLIModule::tr(
"An error occurred when attempting to read from the process. "
"For example, the process may not be running.");
break;
case QProcess::ReadError:
errorString = QLatin1String(
errorString = qSlicerCLIModule::tr(
"An error occurred when attempting to read from the process. "
"For example, the process may not be running.");
break;
case QProcess::UnknownError:
errorString = QLatin1String(
errorString = qSlicerCLIModule::tr(
"Failed to execute process. An unknown error occurred.");
break;
}
Expand All @@ -186,7 +186,7 @@ QString qSlicerCLIExecutableModuleFactoryItem::runCLIWithXmlArgument()
QString errors = cli.readAllStandardError();
if (!errors.isEmpty())
{
this->appendInstantiateErrorString(QString("CLI executable: %1").arg(this->path()));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI executable: %1").arg(this->path()));
this->appendInstantiateErrorString(errors);
// TODO: More investigation for the following behavior:
// on my machine (Ubuntu 10.04 with ITKv4), having standard error trims the
Expand All @@ -198,15 +198,15 @@ QString qSlicerCLIExecutableModuleFactoryItem::runCLIWithXmlArgument()
QString xmlDescription = cli.readAllStandardOutput();
if (xmlDescription.isEmpty())
{
this->appendInstantiateErrorString(QString("CLI executable: %1").arg(this->path()));
this->appendInstantiateErrorString("Failed to retrieve Xml Description");
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI executable: %1").arg(this->path()));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("Failed to retrieve XML Description"));
return QString();
}
if (!xmlDescription.startsWith("<?xml"))
{
this->appendInstantiateWarningString(QString("CLI executable: %1").arg(this->path()));
this->appendInstantiateWarningString(QLatin1String("XML description doesn't start right away."));
this->appendInstantiateWarningString(QString("Output before '<?xml' is [%1]").arg(
this->appendInstantiateWarningString(qSlicerCLIModule::tr("CLI executable: %1").arg(this->path()));
this->appendInstantiateWarningString(qSlicerCLIModule::tr("XML description doesn't start right away."));
this->appendInstantiateWarningString(qSlicerCLIModule::tr("Output before '<?xml' is [%1]").arg(
xmlDescription.mid(0, xmlDescription.indexOf("<?xml"))));
xmlDescription.remove(0, xmlDescription.indexOf("<?xml"));
}
Expand Down
14 changes: 7 additions & 7 deletions Base/QTCLI/qSlicerCLILoadableModuleFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ qSlicerAbstractCoreModule* qSlicerCLILoadableModuleFactoryItem::instanciator()
}
else
{
this->appendInstantiateErrorString(QString("CLI description: %1").arg(xmlFilePath));
this->appendInstantiateErrorString("Failed to read Xml Description");
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI description: %1").arg(xmlFilePath));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("Failed to read XML Description"));
return nullptr;
}
// Set callback to allow lazy loading of target symbols.
Expand Down Expand Up @@ -154,8 +154,8 @@ QString qSlicerCLILoadableModuleFactoryItem::resolveXMLModuleDescriptionSymbol()

if (!xmlDescription)
{
this->appendInstantiateErrorString(QString("CLI loadable: %1").arg(this->path()));
this->appendInstantiateErrorString("Failed to retrieve Xml Description");
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI loadable: %1").arg(this->path()));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("Failed to retrieve XML Description"));
return QString();
}
return QString(xmlDescription);
Expand All @@ -172,8 +172,8 @@ bool qSlicerCLILoadableModuleFactoryItem::resolveSymbols(ModuleDescription& desc

if (!moduleEntryPoint)
{
this->appendInstantiateErrorString(QString("CLI loadable: %1").arg(this->path()));
this->appendInstantiateErrorString("Failed to retrieve Module Entry Point");
this->appendInstantiateErrorString(qSlicerCLIModule::tr("CLI loadable: %1").arg(this->path()));
this->appendInstantiateErrorString(qSlicerCLIModule::tr("Failed to retrieve Module Entry Point"));
return false;
}

Expand Down Expand Up @@ -233,7 +233,7 @@ bool qSlicerCLILoadableModuleFactoryItem::updateLogo(qSlicerCLILoadableModuleFac
}
else
{
item->appendLoadErrorString(QString("Failed to resolve expected symbol '%1'").arg(symbol));
item->appendLoadErrorString(qSlicerCLIModule::tr("Failed to resolve expected symbol '%1'").arg(symbol));
}
}
if (resolvedSymbols.count() == 4)
Expand Down
4 changes: 2 additions & 2 deletions Base/QTCLI/qSlicerCLIModuleUIHelper.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ QWidget* qSlicerCLIModuleUIHelperPrivate::createFileTagWidget(const ModuleParame
const std::vector< std::string > fileExtensionsStd = moduleParameter.GetFileExtensions();
if (!fileExtensionsStd.empty())
{
QString customFilter("Compatible Files (");
QString customFilter(qSlicerCLIModuleUIHelper::tr("Compatible Files") + " (");
for (std::vector< std::string >::const_iterator it = fileExtensionsStd.begin();
it != fileExtensionsStd.end(); ++it)
{
Expand All @@ -942,7 +942,7 @@ QWidget* qSlicerCLIModuleUIHelperPrivate::createFileTagWidget(const ModuleParame
customFilter.append(")");
fileExtensions << customFilter;
}
fileExtensions << QString("All Files (*.*)");
fileExtensions << QString(qSlicerCLIModuleUIHelper::tr("All Files") + " (*.*)");

QWidget* widget = new QWidget;
ctkPathLineEdit* pathLineEdit =
Expand Down

0 comments on commit a0bd3f1

Please sign in to comment.