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()) { if (keysToRemove.isEmpty()) {
QMessageBox::information(0, tr("KeePassXC: No keys found"), 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); QMessageBox::Ok);
return; return;
} }

View file

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

View file

@ -477,7 +477,7 @@ Database* Database::unlockFromStdin(QString databaseFilename, QString keyFilenam
FileKey fileKey; FileKey fileKey;
QString errorMessage; QString errorMessage;
if (!fileKey.load(keyFilename, &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; errorTextStream << endl;
return nullptr; return nullptr;
} }

View file

@ -53,9 +53,9 @@ AboutDialog::AboutDialog(QWidget* parent)
} }
QString debugInfo = "KeePassXC - "; 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 #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 #endif
if (!commitHash.isEmpty()) { if (!commitHash.isEmpty()) {
debugInfo.append(tr("Revision: %1").arg(commitHash.left(7)).append("\n")); debugInfo.append(tr("Revision: %1").arg(commitHash.left(7)).append("\n"));

View file

@ -85,7 +85,7 @@ void ChangeMasterKeyWidget::createKeyFile()
QString errorMsg; QString errorMsg;
bool created = FileKey::create(fileName, &errorMsg); bool created = FileKey::create(fileName, &errorMsg);
if (!created) { 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 { else {
m_ui->keyFileCombo->setEditText(fileName); m_ui->keyFileCombo->setEditText(fileName);
@ -159,7 +159,7 @@ void ChangeMasterKeyWidget::generateKey()
QString fileKeyName = m_ui->keyFileCombo->currentText(); QString fileKeyName = m_ui->keyFileCombo->currentText();
if (!fileKey.load(fileKeyName, &errorMsg)) { if (!fileKey.load(fileKeyName, &errorMsg)) {
m_ui->messageWidget->showMessage( 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; return;
} }
if (fileKey.type() != FileKey::Hashed) { if (fileKey.type() != FileKey::Hashed) {

View file

@ -214,7 +214,7 @@ QSharedPointer<CompositeKey> DatabaseOpenWidget::databaseKey()
QString keyFilename = m_ui->comboKeyFile->currentText(); QString keyFilename = m_ui->comboKeyFile->currentText();
QString errorMsg; QString errorMsg;
if (!key.load(keyFilename, &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); MessageWidget::Error);
return QSharedPointer<CompositeKey>(); return QSharedPointer<CompositeKey>();
} }

View file

@ -50,7 +50,7 @@ void DatabaseRepairWidget::openDatabase()
QString keyFilename = m_ui->comboKeyFile->currentText(); QString keyFilename = m_ui->comboKeyFile->currentText();
QString errorMsg; QString errorMsg;
if (!key.load(keyFilename, &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); emit editFinished(false);
return; return;
} }

View file

@ -47,7 +47,7 @@ SearchWidget::SearchWidget(QWidget* parent)
m_ui->searchEdit->installEventFilter(this); m_ui->searchEdit->installEventFilter(this);
QMenu* searchMenu = new QMenu(); 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->setObjectName("actionSearchCaseSensitive");
m_actionCaseSensitive->setCheckable(true); m_actionCaseSensitive->setCheckable(true);

View file

@ -72,7 +72,7 @@ void TotpDialog::updateProgressBar()
void TotpDialog::updateSeconds() void TotpDialog::updateSeconds()
{ {
uint epoch = QDateTime::currentDateTime().toTime_t() - 1; 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() void TotpDialog::updateTotp()

View file

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

View file

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

View file

@ -916,7 +916,7 @@ void EditEntryWidget::insertAttribute()
int i = 1; int i = 1;
while (m_entryAttributes->keys().contains(name)) { while (m_entryAttributes->keys().contains(name)) {
name = QString("%1 %2").arg(tr("New attribute")).arg(i); name = tr("New attribute %1").arg(i);
i++; i++;
} }
@ -979,7 +979,7 @@ void EditEntryWidget::displayAttribute(QModelIndex index, bool showProtected)
if (index.isValid()) { if (index.isValid()) {
QString key = m_attributesModel->keyByIndex(index); QString key = m_attributesModel->keyByIndex(index);
if (showProtected) { 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->attributesEdit->setEnabled(false);
m_advancedUi->revealAttributeButton->setEnabled(true); m_advancedUi->revealAttributeButton->setEnabled(true);
m_advancedUi->protectAttributeButton->setChecked(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()); 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); question, QMessageBox::Yes | QMessageBox::No);
if (answer == QMessageBox::Yes) { if (answer == QMessageBox::Yes) {
QStringList keys; QStringList keys;