Improve string formatting and context

This commit is contained in:
Emir SARI 2023-10-23 13:39:26 +03:00
parent 8bd2d684b9
commit 682cbe6951
6 changed files with 30 additions and 30 deletions

View File

@ -153,10 +153,10 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details; cDebug() << Logger::SubEntry << "- details:" << Logger::NoQuote << details;
QString heading QString heading
= Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed" ) : tr( "Installation Failed" ); = Calamares::Settings::instance()->isSetupMode() ? tr( "Setup Failed", "@title" ) : tr( "Installation Failed", "@title" );
ErrorDialog* errorDialog = new ErrorDialog(); ErrorDialog* errorDialog = new ErrorDialog();
errorDialog->setWindowTitle( tr( "Error" ) ); errorDialog->setWindowTitle( tr( "Error", "@title" ) );
errorDialog->setHeading( "<strong>" + heading + "</strong>" ); errorDialog->setHeading( "<strong>" + heading + "</strong>" );
errorDialog->setInformativeText( message ); errorDialog->setInformativeText( message );
errorDialog->setShouldOfferWebPaste( Calamares::Branding::instance()->uploadServer() ); errorDialog->setShouldOfferWebPaste( Calamares::Branding::instance()->uploadServer() );
@ -181,14 +181,14 @@ ViewManager::onInitFailed( const QStringList& modules )
{ {
// Because this means the installer / setup program is broken by the distributor, // Because this means the installer / setup program is broken by the distributor,
// don't bother being precise about installer / setup wording. // don't bother being precise about installer / setup wording.
QString title( tr( "Calamares Initialization Failed" ) ); QString title( tr( "Calamares Initialization Failed", "@title" ) );
QString description( tr( "%1 can not be installed. Calamares was unable to load all of the configured modules. " QString description( tr( "%1 can not be installed. Calamares was unable to load all of the configured modules. "
"This is a problem with the way Calamares is being used by the distribution." ) ); "This is a problem with the way Calamares is being used by the distribution.", "@info" ) );
QString detailString; QString detailString;
if ( modules.count() > 0 ) if ( modules.count() > 0 )
{ {
description.append( tr( "<br/>The following modules could not be loaded:" ) ); description.append( tr( "<br/>The following modules could not be loaded:", "@info" ) );
QStringList details; QStringList details;
details << QLatin1String( "<ul>" ); details << QLatin1String( "<ul>" );
for ( const auto& m : modules ) for ( const auto& m : modules )
@ -330,22 +330,22 @@ ViewManager::next()
if ( settings->showPromptBeforeExecution() && stepIsExecute( m_steps, m_currentStep + 1 ) ) if ( settings->showPromptBeforeExecution() && stepIsExecute( m_steps, m_currentStep + 1 ) )
{ {
QString title QString title
= settings->isSetupMode() ? tr( "Continue with setup?" ) : tr( "Continue with installation?" ); = settings->isSetupMode() ? tr( "Continue with Setup?", "@title" ) : tr( "Continue with Installation?", "@title" );
QString question = settings->isSetupMode() QString question = settings->isSetupMode()
? tr( "The %1 setup program is about to make changes to your " ? tr( "The %1 setup program is about to make changes to your "
"disk in order to set up %2.<br/><strong>You will not be able " "disk in order to set up %2.<br/><strong>You will not be able "
"to undo these changes.</strong>" ) "to undo these changes.</strong>", "%1 is short product name, %2 is short product name with version" )
: tr( "The %1 installer is about to make changes to your " : tr( "The %1 installer is about to make changes to your "
"disk in order to install %2.<br/><strong>You will not be able " "disk in order to install %2.<br/><strong>You will not be able "
"to undo these changes.</strong>" ); "to undo these changes.</strong>", "%1 is short product name, %2 is short product name with version" );
QString confirm = settings->isSetupMode() ? tr( "&Set up now" ) : tr( "&Install now" ); QString confirm = settings->isSetupMode() ? tr( "&Set Up Now", "@button" ) : tr( "&Install Now", "@button" );
const auto* branding = Calamares::Branding::instance(); const auto* branding = Calamares::Branding::instance();
int reply = questionBox( m_widget, int reply = questionBox( m_widget,
title, title,
question.arg( branding->shortProductName(), branding->shortVersionedName() ), question.arg( branding->shortProductName(), branding->shortVersionedName() ),
confirm, confirm,
tr( "Go &back" ) ); tr( "Go &Back", "@button" ) );
if ( reply == 1 ) if ( reply == 1 )
{ {
return; return;
@ -392,13 +392,13 @@ ViewManager::updateButtonLabels()
{ {
const auto* const settings = Calamares::Settings::instance(); const auto* const settings = Calamares::Settings::instance();
QString nextIsInstallationStep = settings->isSetupMode() ? tr( "&Set up" ) : tr( "&Install" ); QString nextIsInstallationStep = settings->isSetupMode() ? tr( "&Set Up", "@button" ) : tr( "&Install", "@button" );
QString quitOnCompleteTooltip = settings->isSetupMode() QString quitOnCompleteTooltip = settings->isSetupMode()
? tr( "Setup is complete. Close the setup program." ) ? tr( "Setup is complete. Close the setup program.", "@tooltip" )
: tr( "The installation is complete. Close the installer." ); : tr( "The installation is complete. Close the installer.", "@tooltip" );
QString cancelBeforeInstallationTooltip = settings->isSetupMode() QString cancelBeforeInstallationTooltip = settings->isSetupMode()
? tr( "Cancel setup without changing the system." ) ? tr( "Cancel the setup process without changing the system.", "@tooltip" )
: tr( "Cancel installation without changing the system." ); : tr( "Cancel the installation process without changing the system.", "@tooltip" );
// If we're going into the execution step / install phase, other message // If we're going into the execution step / install phase, other message
if ( stepIsExecute( m_steps, m_currentStep + 1 ) ) if ( stepIsExecute( m_steps, m_currentStep + 1 ) )
@ -408,18 +408,18 @@ ViewManager::updateButtonLabels()
} }
else else
{ {
UPDATE_BUTTON_PROPERTY( nextLabel, tr( "&Next" ) ); UPDATE_BUTTON_PROPERTY( nextLabel, tr( "&Next", "@button" ) );
UPDATE_BUTTON_PROPERTY( nextIcon, "go-next" ); UPDATE_BUTTON_PROPERTY( nextIcon, "go-next" );
} }
// Going back is always simple // Going back is always simple
UPDATE_BUTTON_PROPERTY( backLabel, tr( "&Back" ) ); UPDATE_BUTTON_PROPERTY( backLabel, tr( "&Back", "@button" ) );
UPDATE_BUTTON_PROPERTY( backIcon, "go-previous" ); UPDATE_BUTTON_PROPERTY( backIcon, "go-previous" );
// Cancel button changes label at the end // Cancel button changes label at the end
if ( isAtVeryEnd( m_steps, m_currentStep ) ) if ( isAtVeryEnd( m_steps, m_currentStep ) )
{ {
UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Done" ) ); UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Done", "@button" ) );
UPDATE_BUTTON_PROPERTY( quitTooltip, quitOnCompleteTooltip ); UPDATE_BUTTON_PROPERTY( quitTooltip, quitOnCompleteTooltip );
UPDATE_BUTTON_PROPERTY( quitVisible, true ); UPDATE_BUTTON_PROPERTY( quitVisible, true );
UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-ok-apply" ); UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-ok-apply" );
@ -438,7 +438,7 @@ ViewManager::updateButtonLabels()
updateCancelEnabled( !settings->disableCancel() updateCancelEnabled( !settings->disableCancel()
&& !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) ); && !( stepIsExecute( m_steps, m_currentStep ) && settings->disableCancelDuringExec() ) );
UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Cancel" ) ); UPDATE_BUTTON_PROPERTY( quitLabel, tr( "&Cancel", "@button" ) );
UPDATE_BUTTON_PROPERTY( quitTooltip, cancelBeforeInstallationTooltip ); UPDATE_BUTTON_PROPERTY( quitTooltip, cancelBeforeInstallationTooltip );
UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-cancel" ); UPDATE_BUTTON_PROPERTY( quitIcon, "dialog-cancel" );
} }
@ -510,7 +510,7 @@ ViewManager::confirmCancelInstallation()
} }
// Otherwise, confirm cancel/quit. // Otherwise, confirm cancel/quit.
QString title = settings->isSetupMode() ? tr( "Cancel setup?" ) : tr( "Cancel installation?" ); QString title = settings->isSetupMode() ? tr( "Cancel Setup?", "@title" ) : tr( "Cancel Installation?", "@title" );
QString question = settings->isSetupMode() ? tr( "Do you really want to cancel the current setup process?\n" QString question = settings->isSetupMode() ? tr( "Do you really want to cancel the current setup process?\n"
"The setup program will quit and all changes will be lost." ) "The setup program will quit and all changes will be lost." )
: tr( "Do you really want to cancel the current install process?\n" : tr( "Do you really want to cancel the current install process?\n"

View File

@ -113,7 +113,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
QString QString
ExecutionViewStep::prettyName() const ExecutionViewStep::prettyName() const
{ {
return Calamares::Settings::instance()->isSetupMode() ? tr( "Set up" ) : tr( "Install" ); return Calamares::Settings::instance()->isSetupMode() ? tr( "Set Up", "@label" ) : tr( "Install", "@label" );
} }
QWidget* QWidget*

View File

@ -70,7 +70,7 @@ namespace Calamares
QmlViewStep::QmlViewStep( QObject* parent ) QmlViewStep::QmlViewStep( QObject* parent )
: ViewStep( parent ) : ViewStep( parent )
, m_widget( new QWidget ) , m_widget( new QWidget )
, m_spinner( new WaitingWidget( tr( "Loading ..." ) ) ) , m_spinner( new WaitingWidget( tr( "Loading", "@status" ) ) )
{ {
Calamares::registerQmlModels(); Calamares::registerQmlModels();
@ -97,7 +97,7 @@ QString
QmlViewStep::prettyName() const QmlViewStep::prettyName() const
{ {
// TODO: query the QML itself // TODO: query the QML itself
return tr( "QML Step <i>%1</i>." ).arg( moduleInstanceKey().module() ); return tr( "QML step <i>%1</i>.", "@label" ).arg( moduleInstanceKey().module() );
} }
bool bool
@ -283,7 +283,7 @@ QmlViewStep::showFailedQml()
{ {
cDebug() << Logger::SubEntry << "QML error:" << m_qmlComponent->errorString(); cDebug() << Logger::SubEntry << "QML error:" << m_qmlComponent->errorString();
} }
m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) ); m_spinner->setText( prettyName() + ' ' + tr( "Loading failed.", "@info" ) );
} }
QObject* QObject*

View File

@ -110,9 +110,9 @@ ContextualProcessJob::~ContextualProcessJob()
} }
QString QString
ContextualProcessJob::prettyName() const CntextualProcessJob::prettyName() const
{ {
return tr( "Contextual Processes Job" ); return tr( "Performing contextual processes' job…", "@status" );
} }
Calamares::JobResult Calamares::JobResult

View File

@ -114,11 +114,11 @@ DracutLuksCfgJob::prettyName() const
{ {
if ( isRootEncrypted() ) if ( isRootEncrypted() )
{ {
return tr( "Write LUKS configuration for Dracut to %1" ).arg( CONFIG_FILE ); return tr( "Writing LUKS configuration for Dracut to %1…", "@status" ).arg( CONFIG_FILE );
} }
else else
{ {
return tr( "Skip writing LUKS configuration for Dracut: \"/\" partition is not encrypted" ); return tr( "Skipping writing LUKS configuration for Dracut: \"/\" partition is not encrypted", "@info" );
} }
} }
@ -135,7 +135,7 @@ DracutLuksCfgJob::exec()
if ( !configFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) if ( !configFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
{ {
cDebug() << "[DRACUTLUKSCFG]: Failed to open" << realConfigFilePath; cDebug() << "[DRACUTLUKSCFG]: Failed to open" << realConfigFilePath;
return Calamares::JobResult::error( tr( "Failed to open %1" ).arg( realConfigFilePath ) ); return Calamares::JobResult::error( tr( "Failed to open %1", "@error" ).arg( realConfigFilePath ) );
} }
QTextStream outStream( &configFile ); QTextStream outStream( &configFile );
outStream << CONFIG_FILE_HEADER outStream << CONFIG_FILE_HEADER

View File

@ -32,7 +32,7 @@ DummyCppJob::~DummyCppJob() {}
QString QString
DummyCppJob::prettyName() const DummyCppJob::prettyName() const
{ {
return tr( "Dummy C++ Job" ); return tr( "Performing dummy C++ job…", "@status" );
} }
static QString variantListToString( const QVariantList& variantList ); static QString variantListToString( const QVariantList& variantList );