Fix weird base strings and reduce concatenation

This commit is contained in:
Edward Jones 2018-03-13 19:59:08 +00:00
parent e718e9f5e5
commit 3def6a3bc4
13 changed files with 26 additions and 25 deletions

View File

@ -437,7 +437,7 @@ void BrowserService::removeSharedEncryptionKeys()
if (keysToRemove.isEmpty()) {
QMessageBox::information(0, tr("KeePassXC: No keys found"),
tr("No shared encryption keys found in KeePassXC Settings."),
tr("No shared encryption keys found in KeePassXC settings."),
QMessageBox::Ok);
return;
}

View File

@ -84,7 +84,7 @@ bool CsvParser::readFile(QFile *device) {
m_array.replace("\r\n", "\n");
m_array.replace("\r", "\n");
if (0 == m_array.size())
appendStatusMsg(QObject::tr("file empty !\n"));
appendStatusMsg(QObject::tr("file empty").append("\n"));
m_isFileLoaded = true;
}
return m_isFileLoaded;

View File

@ -477,7 +477,7 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam
FileKey fileKey;
QString errorMessage;
if (!fileKey.load(keyFilename, &errorMessage)) {
errorTextStream << QObject::tr("Failed to load key file %1 : %2").arg(keyFilename, errorMessage);
errorTextStream << QObject::tr("Failed to load key file %1: %2").arg(keyFilename, errorMessage);
errorTextStream << endl;
return nullptr;
}

View File

@ -53,9 +53,9 @@ AboutDialog::AboutDialog(QWidget* parent)
}
QString debugInfo = "KeePassXC - ";
debugInfo.append(tr("Version %1\n").arg(KEEPASSX_VERSION));
debugInfo.append(tr("Version %1").arg(KEEPASSX_VERSION).append("\n"));
#ifndef KEEPASSXC_BUILD_TYPE_RELEASE
debugInfo.append(tr("Build Type: %1\n").arg(KEEPASSXC_BUILD_TYPE));
debugInfo.append(tr("Build Type: %1").arg(KEEPASSXC_BUILD_TYPE).append("\n"));
#endif
if (!commitHash.isEmpty()) {
debugInfo.append(tr("Revision: %1").arg(commitHash.left(7)).append("\n"));

View File

@ -85,7 +85,7 @@ void ChangeMasterKeyWidget::createKeyFile()
QString errorMsg;
bool created = FileKey::create(fileName, &errorMsg);
if (!created) {
m_ui->messageWidget->showMessage(tr("Unable to create Key File : ").append(errorMsg), MessageWidget::Error);
m_ui->messageWidget->showMessage(tr("Unable to create key file: %1").arg(errorMsg), MessageWidget::Error);
}
else {
m_ui->keyFileCombo->setEditText(fileName);
@ -159,7 +159,7 @@ void ChangeMasterKeyWidget::generateKey()
QString fileKeyName = m_ui->keyFileCombo->currentText();
if (!fileKey.load(fileKeyName, &errorMsg)) {
m_ui->messageWidget->showMessage(
tr("Failed to set %1 as the Key file:\n%2").arg(fileKeyName, errorMsg), MessageWidget::Error);
tr("Failed to set %1 as the key file:\n%2").arg(fileKeyName, errorMsg), MessageWidget::Error);
return;
}
if (fileKey.type() != FileKey::Hashed) {

View File

@ -214,7 +214,7 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::databaseKey()
QString keyFilename = m_ui->comboKeyFile->currentText();
QString errorMsg;
if (!key.load(keyFilename, &errorMsg)) {
m_ui->messageWidget->showMessage(tr("Can't open key file").append(":\n").append(errorMsg),
m_ui->messageWidget->showMessage(tr("Can't open key file:\n%1").arg(errorMsg),
MessageWidget::Error);
return QSharedPointer<CompositeKey>();
}

View File

@ -50,7 +50,7 @@ void DatabaseRepairWidget::openDatabase()
QString keyFilename = m_ui->comboKeyFile->currentText();
QString errorMsg;
if (!key.load(keyFilename, &errorMsg)) {
MessageBox::warning(this, tr("Error"), tr("Can't open key file").append(":\n").append(errorMsg));
MessageBox::warning(this, tr("Error"), tr("Can't open key file:\n%1").arg(errorMsg));
emit editFinished(false);
return;
}

View File

@ -47,7 +47,7 @@ SearchWidget::SearchWidget(QWidget* parent)
m_ui->searchEdit->installEventFilter(this);
QMenu* searchMenu = new QMenu();
m_actionCaseSensitive = searchMenu->addAction(tr("Case Sensitive"), this, SLOT(updateCaseSensitive()));
m_actionCaseSensitive = searchMenu->addAction(tr("Case sensitive"), this, SLOT(updateCaseSensitive()));
m_actionCaseSensitive->setObjectName("actionSearchCaseSensitive");
m_actionCaseSensitive->setCheckable(true);

View File

@ -72,7 +72,7 @@ void TotpDialog::updateProgressBar()
void TotpDialog::updateSeconds()
{
uint epoch = QDateTime::currentDateTime().toTime_t() - 1;
m_ui->timerLabel->setText(tr("Expires in") + " <b>" + QString::number(m_step - (epoch % m_step)) + "</b> " + tr("seconds"));
m_ui->timerLabel->setText(tr("Expires in <b>%n</b> second(s)", "", m_step - (epoch % m_step)));
}
void TotpDialog::updateTotp()

View File

@ -151,10 +151,10 @@ void CsvImportWidget::updatePreview() {
if (m_ui->checkBoxFieldNames->isChecked()) {
columnName = m_parserModel->getCsvTable().at(0).at(i);
if (columnName.isEmpty())
columnName = "<" + tr("Empty fieldname ") + QString::number(++emptyId) + ">";
columnName = "<" + tr("Empty fieldname %1").arg(++emptyId) + ">";
list << columnName;
} else {
list << QString(tr("column ")) + QString::number(i);
list << QString(tr("column %1").arg(i));
}
}
m_comboModel->setStringList(list);
@ -176,7 +176,7 @@ void CsvImportWidget::load(const QString& filename, Database* const db) {
m_ui->labelFilename->setText(filename);
Group* group = m_db->rootGroup();
group->setUuid(Uuid::random());
group->setNotes(tr("Imported from CSV file").append("\n").append(tr("Original data: ")) + filename);
group->setNotes(tr("Imported from CSV file\nOriginal data: %1").arg(filename));
parse();
}
@ -188,7 +188,7 @@ void CsvImportWidget::parse() {
updatePreview();
QApplication::restoreOverrideCursor();
if (!good)
m_ui->messageWidget->showMessage(tr("Error(s) detected in CSV file !").append("\n")
m_ui->messageWidget->showMessage(tr("Error(s) detected in CSV file!").append("\n")
.append(formatStatusText()), MessageWidget::Warning);
else
m_ui->messageWidget->setHidden(true);
@ -201,8 +201,8 @@ QString CsvImportWidget::formatStatusText() const {
int items = text.count('\n');
if (items > 2) {
return text.section('\n', 0, 1)
.append("\n[").append(QString::number(items - 2))
.append(tr(" more messages skipped]"));
.append("\n")
.append(tr("[%n more message(s) skipped]", "", items - 2));
}
if (items == 1) {
text.append(QString("\n"));
@ -247,8 +247,8 @@ void CsvImportWidget::writeDatabase() {
KeePass2Writer writer;
writer.writeDatabase(&buffer, m_db);
if (writer.hasError())
MessageBox::warning(this, tr("Error"), tr("CSV import: writer has errors:\n")
.append((writer.errorString())), QMessageBox::Ok, QMessageBox::Ok);
MessageBox::warning(this, tr("Error"), tr("CSV import: writer has errors:\n%1")
.arg(writer.errorString()), QMessageBox::Ok, QMessageBox::Ok);
emit editFinished(true);
}

View File

@ -31,9 +31,10 @@ void CsvParserModel::setFilename(const QString& filename) {
}
QString CsvParserModel::getFileInfo(){
QString a(tr("%n byte(s), ", nullptr, getFileSize()));
a.append(tr("%n row(s), ", nullptr, getCsvRows()));
a.append(tr("%n column(s)", nullptr, qMax(0, getCsvCols() - 1)));
QString a(tr("%1, %2, %3", "file info: bytes, rows, columns")
.arg(tr("%n byte(s)", nullptr, getFileSize()))
.arg(tr("%n row(s)", nullptr, getCsvRows()))
.arg(tr("%n column(s)", nullptr, qMax(0, getCsvCols() - 1))));
return a;
}

View File

@ -916,7 +916,7 @@ void EditEntryWidget::insertAttribute()
int i = 1;
while (m_entryAttributes->keys().contains(name)) {
name = QString("%1 %2").arg(tr("New attribute")).arg(i);
name = tr("New attribute %1").arg(i);
i++;
}
@ -979,7 +979,7 @@ void EditEntryWidget::displayAttribute(QModelIndex index, bool showProtected)
if (index.isValid()) {
QString key = m_attributesModel->keyByIndex(index);
if (showProtected) {
m_advancedUi->attributesEdit->setPlainText(tr("[PROTECTED]") + " " + tr("Press reveal to view or edit"));
m_advancedUi->attributesEdit->setPlainText(tr("[PROTECTED] Press reveal to view or edit"));
m_advancedUi->attributesEdit->setEnabled(false);
m_advancedUi->revealAttributeButton->setEnabled(true);
m_advancedUi->protectAttributeButton->setChecked(true);

View File

@ -162,7 +162,7 @@ void EntryAttachmentsWidget::removeSelectedAttachments()
}
const QString question = tr("Are you sure you want to remove %n attachment(s)?", "", indexes.count());
QMessageBox::StandardButton answer = MessageBox::question(this, tr("Confirm Remove"),
QMessageBox::StandardButton answer = MessageBox::question(this, tr("Confirm remove"),
question, QMessageBox::Yes | QMessageBox::No);
if (answer == QMessageBox::Yes) {
QStringList keys;