Merge pull request #2210 from bitigchi/strings

Improve string formatting and context
This commit is contained in:
Adriaan de Groot 2023-10-22 13:50:38 +02:00 committed by GitHub
commit 4297a00537
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 20 deletions

View File

@ -36,13 +36,20 @@ ProcessJob::~ProcessJob() {}
QString
ProcessJob::prettyName() const
{
return ( m_runInChroot ? tr( "Run command '%1' in target system." ) : tr( " Run command '%1'." ) ).arg( m_command );
return ( m_runInChroot ? "Run command '%1' in target system" : "Run command '%1'" ).arg( m_command );
}
QString
ProcessJob::prettyStatusMessage() const
{
return tr( "Running command %1 %2" ).arg( m_command ).arg( m_runInChroot ? "in chroot." : " ." );
if ( m_runInChroot )
{
return tr( "Running command %1 in target system…", "@status" ).arg( m_command );
}
else
{
return tr( "Running command %1…", "@status" ).arg( m_command );
}
}
JobResult

View File

@ -304,7 +304,7 @@ Helper::handleLastError()
if ( typeMsg.isEmpty() )
{
typeMsg = tr( "Unknown exception type" );
typeMsg = tr( "Unknown exception type", "@error" );
}
debug << typeMsg << '\n';
}
@ -322,7 +322,7 @@ Helper::handleLastError()
if ( valMsg.isEmpty() )
{
valMsg = tr( "unparseable Python error" );
valMsg = tr( "Unparseable Python error", "@error" );
}
// Special-case: CalledProcessError has an attribute "output" with the command output,
@ -366,14 +366,14 @@ Helper::handleLastError()
if ( tbMsg.isEmpty() )
{
tbMsg = tr( "unparseable Python traceback" );
tbMsg = tr( "Unparseable Python traceback", "@error" );
}
debug << tbMsg << '\n';
}
if ( typeMsg.isEmpty() && valMsg.isEmpty() && tbMsg.isEmpty() )
{
return tr( "Unfetchable Python error." );
return tr( "Unfetchable Python error", "@error" );
}
QStringList msgList;

View File

@ -230,7 +230,7 @@ PythonJob::prettyStatusMessage() const
// The description is updated when progress is reported, see emitProgress()
if ( m_description.isEmpty() )
{
return tr( "Running %1 operation." ).arg( QDir( m_workingPath ).dirName() );
return tr( "Running %1 operation", "@status" ).arg( QDir( m_workingPath ).dirName() );
}
else
{
@ -259,15 +259,15 @@ PythonJob::exec()
if ( !workingDir.exists() || !workingDir.isReadable() )
{
return JobResult::error(
tr( "Bad working directory path" ),
tr( "Working directory %1 for python job %2 is not readable." ).arg( m_workingPath ).arg( prettyName() ) );
tr( "Bad working directory path", "@error" ),
tr( "Working directory %1 for python job %2 is not readable.", "@error" ).arg( m_workingPath ).arg( prettyName() ) );
}
QFileInfo scriptFI( workingDir.absoluteFilePath( m_scriptFile ) );
if ( !scriptFI.exists() || !scriptFI.isFile() || !scriptFI.isReadable() )
{
return JobResult::error( tr( "Bad main script file" ),
tr( "Main script file %1 for python job %2 is not readable." )
return JobResult::error( tr( "Bad main script file", "@error" ),
tr( "Main script file %1 for python job %2 is not readable.", "@error" )
.arg( scriptFI.absoluteFilePath() )
.arg( prettyName() ) );
}
@ -340,7 +340,7 @@ PythonJob::exec()
bp::handle_exception();
PyErr_Clear();
return JobResult::internalError(
tr( "Boost.Python error in job \"%1\"." ).arg( prettyName() ), msg, JobResult::PythonUncaughtException );
tr( "Boost.Python error in job \"%1\"", "@error" ).arg( prettyName() ), msg, JobResult::PythonUncaughtException );
}
}

View File

@ -96,7 +96,7 @@ RequirementsChecker::addCheckedRequirements( Module* m )
m_model->addRequirementsList( l );
}
Q_EMIT requirementsProgress( tr( "Requirements checking for module '%1' is complete." ).arg( m->name() ) );
Q_EMIT requirementsProgress( tr( "Requirements checking for module '%1' is complete.", "@info" ).arg( m->name() ) );
}
void
@ -120,13 +120,13 @@ RequirementsChecker::reportProgress()
{
cDebug() << "Remaining modules:" << remaining << Logger::DebugList( remainingNames );
unsigned int posInterval = ( m_progressTimer->interval() < 0 ) ? 1000 : uint( m_progressTimer->interval() );
QString waiting = tr( "Waiting for %n module(s).", "", remaining );
QString elapsed = tr( "(%n second(s))", "", m_progressTimeouts * posInterval / 1000 );
QString waiting = tr( "Waiting for %n module(s)", "@status", remaining );
QString elapsed = tr( "(%n second(s))", "@status", m_progressTimeouts * posInterval / 999 );
Q_EMIT requirementsProgress( waiting + QString( " " ) + elapsed );
}
else
{
Q_EMIT requirementsProgress( tr( "System-requirements checking is complete." ) );
Q_EMIT requirementsProgress( tr( "System-requirements checking is complete.", "@info" ) );
}
}

View File

@ -30,13 +30,13 @@ prettyNameForFileSystemType( FileSystem::Type t )
switch ( t )
{
case FileSystem::Unknown:
return QObject::tr( "unknown" );
return QObject::tr( "unknown", "@partition info" );
case FileSystem::Extended:
return QObject::tr( "extended" );
return QObject::tr( "extended", "@partition info" );
case FileSystem::Unformatted:
return QObject::tr( "unformatted" );
return QObject::tr( "unformatted", "@partition info" );
case FileSystem::LinuxSwap:
return QObject::tr( "swap" );
return QObject::tr( "swap", "@partition info" );
case FileSystem::Fat16:
case FileSystem::Fat32:
case FileSystem::Ntfs: