From e60d981e07e065403920eed6315b33b03283b0af Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Tue, 10 Oct 2023 12:55:31 +0300 Subject: [PATCH 1/3] Improve string formatting and context --- src/libcalamares/ProcessJob.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/ProcessJob.cpp b/src/libcalamares/ProcessJob.cpp index 857078220..dfa02dbfc 100644 --- a/src/libcalamares/ProcessJob.cpp +++ b/src/libcalamares/ProcessJob.cpp @@ -36,13 +36,16 @@ 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 ? tr( "Run command '%1' in target system" ) : tr( " 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 chroot…", "@status" ).arg( m_command ); + else + return tr( "Running command %1…", "@status" ).arg( m_command ); } JobResult From 814f5f0ccc11819bfda229520e9d9bc875e902cb Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Sun, 15 Oct 2023 14:19:57 +0300 Subject: [PATCH 2/3] Improve formatting --- src/libcalamares/ProcessJob.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/ProcessJob.cpp b/src/libcalamares/ProcessJob.cpp index dfa02dbfc..216f0a236 100644 --- a/src/libcalamares/ProcessJob.cpp +++ b/src/libcalamares/ProcessJob.cpp @@ -36,16 +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 { if ( m_runInChroot ) - return tr( "Running command %1 in chroot…", "@status" ).arg( m_command ); + { + return tr( "Running command %1 in target system…", "@status" ).arg( m_command ); + } else + { return tr( "Running command %1…", "@status" ).arg( m_command ); + } } JobResult From 125a58f7c01dc54bd948c4c7585864918882a03e Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Sun, 15 Oct 2023 14:39:17 +0300 Subject: [PATCH 3/3] Process more messages --- src/libcalamares/PythonHelper.cpp | 8 ++++---- src/libcalamares/PythonJob.cpp | 12 ++++++------ .../modulesystem/RequirementsChecker.cpp | 8 ++++---- src/libcalamares/partition/FileSystem.cpp | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index 5a8b5fadb..946c7f9e3 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -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; diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index ec17c31f3..6ead23ec7 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -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 ); } } diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index 32f68ffd7..1eb85113d 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -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" ) ); } } diff --git a/src/libcalamares/partition/FileSystem.cpp b/src/libcalamares/partition/FileSystem.cpp index 9e197d214..c2aedc079 100644 --- a/src/libcalamares/partition/FileSystem.cpp +++ b/src/libcalamares/partition/FileSystem.cpp @@ -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: