edz: make EdzArchive error strings translatable (+ DE/FR)

The six user-facing error strings in EdzArchive::extract() were hard-coded
QStringLiteral, so they could not be translated (reported by plc-user in
PR #513).

Wrap them in tr() via Q_DECLARE_TR_FUNCTIONS — EdzArchive is not a QObject,
so this gives it its own translation context without pulling in a moc
dependency. The *.part.xml glob stays a QStringLiteral: it is a filename
pattern, not user-facing text.

Adds German and French translations for all six. German wording for
"Cannot read %1" is plc-user's ("Kann %1 nicht lesen.").

Note for review: the rest of QET uses French source strings translated to
en/de in the .ts files, whereas these strings are English in the source
(as merged in PR #513). This commit keeps them English rather than
rewriting strings already reviewed; happy to flip them to French sources
for consistency if preferred.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-07-26 21:04:25 +12:00
parent e9a53dbec2
commit 7cb9695962
4 changed files with 75 additions and 6 deletions
+33
View File
@@ -15343,4 +15343,37 @@ Maximale Länge: %2px
<translation>Was:</translation> <translation>Was:</translation>
</message> </message>
</context> </context>
<context>
<name>EdzArchive</name>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="41"/>
<source>File not found: %1</source>
<translation>Datei nicht gefunden: %1</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="50"/>
<source>Cannot read %1</source>
<translation>Kann %1 nicht lesen.</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="58"/>
<source>This .edz is a zip-format package, which is not yet supported (only 7-Zip .edz files can be imported).</source>
<translation>Diese .edz-Datei ist ein Paket im ZIP-Format, das noch nicht unterstützt wird (es können nur .edz-Dateien im 7-Zip-Format importiert werden).</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="62"/>
<source>Not a valid .edz package (unrecognised archive format).</source>
<translation>Kein gültiges .edz-Paket (unbekanntes Archivformat).</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="70"/>
<source>Could not create a temporary directory: %1</source>
<translation>Temporäres Verzeichnis konnte nicht erstellt werden: %1</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="80"/>
<source>No *.part.xml found inside the .edz</source>
<translation>Keine *.part.xml in der .edz-Datei gefunden</translation>
</message>
</context>
</TS> </TS>
+33
View File
@@ -15181,4 +15181,37 @@ Longueur maximale : %2px
<translation></translation> <translation></translation>
</message> </message>
</context> </context>
<context>
<name>EdzArchive</name>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="41"/>
<source>File not found: %1</source>
<translation>Fichier introuvable : %1</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="50"/>
<source>Cannot read %1</source>
<translation>Impossible de lire %1</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="58"/>
<source>This .edz is a zip-format package, which is not yet supported (only 7-Zip .edz files can be imported).</source>
<translation>Ce fichier .edz est un paquet au format zip, qui n&apos;est pas encore pris en charge (seuls les fichiers .edz au format 7-Zip peuvent être importés).</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="62"/>
<source>Not a valid .edz package (unrecognised archive format).</source>
<translation>Paquet .edz non valide (format d&apos;archive non reconnu).</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="70"/>
<source>Could not create a temporary directory: %1</source>
<translation>Impossible de créer un répertoire temporaire : %1</translation>
</message>
<message>
<location filename="../sources/import/edz/edzarchive.cpp" line="80"/>
<source>No *.part.xml found inside the .edz</source>
<translation>Aucun fichier *.part.xml trouvé dans le .edz</translation>
</message>
</context>
</TS> </TS>
+6 -6
View File
@@ -38,7 +38,7 @@ bool EdzArchive::extract(const QString &edz_path)
const QFileInfo fi(edz_path); const QFileInfo fi(edz_path);
if (!fi.exists() || !fi.isFile()) { if (!fi.exists() || !fi.isFile()) {
m_error = QStringLiteral("File not found: %1").arg(edz_path); m_error = tr("File not found: %1").arg(edz_path);
return false; return false;
} }
@@ -47,7 +47,7 @@ bool EdzArchive::extract(const QString &edz_path)
// detect that up front and say so clearly rather than failing opaquely. // detect that up front and say so clearly rather than failing opaquely.
QFile probe(fi.absoluteFilePath()); QFile probe(fi.absoluteFilePath());
if (!probe.open(QIODevice::ReadOnly)) { if (!probe.open(QIODevice::ReadOnly)) {
m_error = QStringLiteral("Cannot read %1").arg(edz_path); m_error = tr("Cannot read %1").arg(edz_path);
return false; return false;
} }
const QByteArray magic = probe.read(6); const QByteArray magic = probe.read(6);
@@ -55,11 +55,11 @@ bool EdzArchive::extract(const QString &edz_path)
static const QByteArray k7z("7z\xBC\xAF\x27\x1C", 6); static const QByteArray k7z("7z\xBC\xAF\x27\x1C", 6);
if (!magic.startsWith(k7z)) { if (!magic.startsWith(k7z)) {
if (magic.startsWith(QByteArray("PK\x03\x04", 4))) { if (magic.startsWith(QByteArray("PK\x03\x04", 4))) {
m_error = QStringLiteral( m_error = tr(
"This .edz is a zip-format package, which is not yet " "This .edz is a zip-format package, which is not yet "
"supported (only 7-Zip .edz files can be imported)."); "supported (only 7-Zip .edz files can be imported).");
} else { } else {
m_error = QStringLiteral( m_error = tr(
"Not a valid .edz package (unrecognised archive format)."); "Not a valid .edz package (unrecognised archive format).");
} }
return false; return false;
@@ -67,7 +67,7 @@ bool EdzArchive::extract(const QString &edz_path)
m_dir.reset(new QTemporaryDir); m_dir.reset(new QTemporaryDir);
if (!m_dir->isValid()) { if (!m_dir->isValid()) {
m_error = QStringLiteral("Could not create a temporary directory: %1") m_error = tr("Could not create a temporary directory: %1")
.arg(m_dir->errorString()); .arg(m_dir->errorString());
return false; return false;
} }
@@ -77,7 +77,7 @@ bool EdzArchive::extract(const QString &edz_path)
} }
if (partXmlPath().isEmpty()) { if (partXmlPath().isEmpty()) {
m_error = QStringLiteral("No *.part.xml found inside the .edz"); m_error = tr("No *.part.xml found inside the .edz");
return false; return false;
} }
return true; return true;
+3
View File
@@ -18,6 +18,7 @@
#ifndef EDZARCHIVE_H #ifndef EDZARCHIVE_H
#define EDZARCHIVE_H #define EDZARCHIVE_H
#include <QCoreApplication>
#include <QString> #include <QString>
#include <QScopedPointer> #include <QScopedPointer>
@@ -38,6 +39,8 @@ class QTemporaryDir;
*/ */
class EdzArchive class EdzArchive
{ {
Q_DECLARE_TR_FUNCTIONS(EdzArchive)
public: public:
EdzArchive(); EdzArchive();
~EdzArchive(); ~EdzArchive();