Make more strings translatable

Includes making certain modifiers (like "[locked]") positionable, in
case languages put this before the word
This commit is contained in:
Edward Jones 2018-03-13 20:02:38 +00:00
parent 3def6a3bc4
commit e66adfbf68
10 changed files with 24 additions and 25 deletions

View File

@ -377,10 +377,8 @@ int CsvParser::getCsvRows() const {
void CsvParser::appendStatusMsg(QString s, bool isCritical) {
m_statusMsg += s
.append(": (row,col) " + QString::number(m_currRow))
.append(",")
.append(QString::number(m_currCol))
m_statusMsg += QObject::tr("%1: (row, col) %2,%3")
.arg(s, m_currRow, m_currCol)
.append("\n");
m_isGood = !isCritical;
}

View File

@ -681,7 +681,7 @@ Entry* Entry::clone(CloneFlags flags) const
}
if (flags & CloneRenameTitle)
entry->setTitle(entry->title() + tr(" - Clone", "Suffix added to cloned entries"));
entry->setTitle(tr("%1 - Clone").arg(entry->title()));
return entry;
}

View File

@ -616,7 +616,7 @@ QString Group::print(bool recursive, int depth)
QString indentation = QString(" ").repeated(depth);
if (entries().isEmpty() && children().isEmpty()) {
response += indentation + "[empty]\n";
response += indentation + tr("[empty]", "group has no children") + "\n";
return response;
}
@ -911,7 +911,7 @@ void Group::markOlderEntry(Entry* entry)
{
entry->attributes()->set(
"merged",
QString("older entry merged from database \"%1\"").arg(entry->group()->database()->metadata()->name()));
tr("older entry merged from database \"%1\"").arg(entry->group()->database()->metadata()->name()));
}
bool Group::resolveSearchingEnabled() const

View File

@ -42,7 +42,7 @@ Database* Kdbx3Reader::readDatabaseImpl(QIODevice* device, const QByteArray& hea
if (m_masterSeed.isEmpty() || m_encryptionIV.isEmpty()
|| m_streamStartBytes.isEmpty() || m_protectedStreamKey.isEmpty()
|| m_db->cipher().isNull()) {
raiseError("missing database headers");
raiseError(tr("missing database headers"));
return nullptr;
}
@ -134,7 +134,7 @@ Database* Kdbx3Reader::readDatabaseImpl(QIODevice* device, const QByteArray& hea
if (!xmlReader.headerHash().isEmpty()) {
QByteArray headerHash = CryptoHash::hash(headerData, CryptoHash::Sha256);
if (headerHash != xmlReader.headerHash()) {
raiseError("Header doesn't match hash");
raiseError(tr("Header doesn't match hash"));
return nullptr;
}
}
@ -146,7 +146,7 @@ bool Kdbx3Reader::readHeaderField(StoreDataStream& headerStream)
{
QByteArray fieldIDArray = headerStream.read(1);
if (fieldIDArray.size() != 1) {
raiseError("Invalid header id size");
raiseError(tr("Invalid header id size"));
return false;
}
char fieldID = fieldIDArray.at(0);
@ -154,7 +154,7 @@ bool Kdbx3Reader::readHeaderField(StoreDataStream& headerStream)
bool ok;
auto fieldLen = Endian::readSizedInt<quint16>(&headerStream, KeePass2::BYTEORDER, &ok);
if (!ok) {
raiseError("Invalid header field length");
raiseError(tr("Invalid header field length"));
return false;
}
@ -162,7 +162,7 @@ bool Kdbx3Reader::readHeaderField(StoreDataStream& headerStream)
if (fieldLen != 0) {
fieldData = headerStream.read(fieldLen);
if (fieldData.size() != fieldLen) {
raiseError("Invalid header data length");
raiseError(tr("Invalid header data length"));
return false;
}
}

View File

@ -179,8 +179,9 @@ QString KdbxXmlReader::errorString() const
{
if (m_error) {
return m_errorStr;
}if (m_xml.hasError()) {
return QString("XML error:\n%1\nLine %2, column %3")
}
if (m_xml.hasError()) {
return tr("XML error:\n%1\nLine %2, column %3")
.arg(m_xml.errorString())
.arg(m_xml.lineNumber())
.arg(m_xml.columnNumber());

View File

@ -363,7 +363,7 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
cipherStream->reset();
cipherStream->close();
if (!m_device->seek(contentPos)) {
QString msg = "unable to seek to content position";
QString msg = tr("unable to seek to content position");
if (!m_device->errorString().isEmpty()) {
msg.append("\n").append(m_device->errorString());
}

View File

@ -82,23 +82,23 @@ AboutDialog::AboutDialog(QWidget* parent)
QString extensions;
#ifdef WITH_XC_AUTOTYPE
extensions += "\n- Auto-Type";
extensions += "\n- " + tr("Auto-Type");
#endif
#ifdef WITH_XC_BROWSER
extensions += "\n- Browser Integration";
extensions += "\n- " + tr("Browser Integration");
#endif
#ifdef WITH_XC_HTTP
extensions += "\n- Legacy Browser Integration (KeePassHTTP)";
extensions += "\n- " + tr("Legacy Browser Integration (KeePassHTTP)");
#endif
#ifdef WITH_XC_SSHAGENT
extensions += "\n- SSH Agent";
extensions += "\n- " + tr("SSH Agent");
#endif
#ifdef WITH_XC_YUBIKEY
extensions += "\n- YubiKey";
extensions += "\n- " + tr("YubiKey");
#endif
if (extensions.isEmpty())
extensions = " None";
extensions = " " + tr("None");
debugInfo.append(tr("Enabled extensions:").append(extensions));

View File

@ -534,12 +534,12 @@ void DatabaseTabWidget::updateTabName(Database* db)
if (db->metadata()->name().isEmpty()) {
tabName = tr("New database");
} else {
tabName = QString("%1 [%2]").arg(db->metadata()->name(), tr("New database"));
tabName = tr("%1 [New database]", "tab modifier").arg(db->metadata()->name());
}
}
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::LockedMode) {
tabName.append(QString(" [%1]").arg(tr("locked")));
tabName = tr("%1 [locked]", "tab modifier").arg(tabName);
}
if (dbStruct.modified) {

View File

@ -216,7 +216,7 @@ void DetailsWidget::updateEntryAttributesTab()
if (m_currentEntry->attributes()->isProtected(key)) {
value = "<i>" + tr("[PROTECTED]") + "</i>";
}
attributesText.append(QString("<b>%1</b>: %2<br/>").arg(key, value));
attributesText.append(tr("<b>%1</b>: %2", "attributes line").arg(key, value).append("<br/>"));
}
m_ui->entryAttributesEdit->setText(attributesText);
}

View File

@ -673,7 +673,7 @@ void MainWindow::updateWindowTitle()
customWindowTitlePart.remove(customWindowTitlePart.size() - 1, 1);
}
if (m_ui->tabWidget->readOnly(tabWidgetIndex)) {
customWindowTitlePart.append(QString(" [%1]").arg(tr("read-only")));
customWindowTitlePart = tr("%1 [read-only]", "window title modifier").arg(customWindowTitlePart);
}
m_ui->actionDatabaseSave->setEnabled(m_ui->tabWidget->canSave(tabWidgetIndex));
} else if (stackedWidgetIndex == 1) {