[Companion] Qualify all translation strings (#5557)

* [Companion] Qualify all remaining QObject translations with proper class/object names; Centralize some common strings into constants.h.

* [Companion] Replace all instances of some common strings with macros from constants.h.

* [Companion] Fix translation warnings from lupdate.
This commit is contained in:
Max Paperno
2017-12-25 13:36:34 +01:00
committed by Bertrand Songis
parent ad0f727880
commit f018425e12
50 changed files with 331 additions and 303 deletions
+6 -6
View File
@@ -39,7 +39,7 @@ bool BinEepromFormat::load(RadioData & radioData)
QByteArray eeprom(size, 0);
int result = file.read((char *)eeprom.data(), size);
if (result != size) {
setError(QObject::tr("Error reading %1: %2").arg(filename).arg(file.errorString()));
setError(tr("Error reading %1: %2").arg(filename).arg(file.errorString()));
return false;
}
@@ -61,7 +61,7 @@ bool BinEepromFormat::write(const RadioData & radioData)
}
else {
// TODO here we could call setError(eepromInterface->errors())
setError(QObject::tr("Cannot save EEPROM"));
setError(tr("Cannot save EEPROM"));
result = false;
}
free(eeprom);
@@ -72,14 +72,14 @@ bool BinEepromFormat::writeToFile(const uint8_t * eeprom, uint32_t size)
{
QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) {
setError(QObject::tr("Cannot open file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Cannot open file %1:\n%2.").arg(filename).arg(file.errorString()));
return false;
}
QTextStream outputStream(&file);
qint64 len = file.write((char *)eeprom, size);
if (len != qint64(size)) {
setError(QObject::tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
return false;
}
@@ -94,7 +94,7 @@ bool BinEepromFormat::extract(RadioData & radioData, const QByteArray & eeprom)
std::bitset<NUM_ERRORS> result((unsigned long long)eepromInterface->load(radioData, (uint8_t *)eeprom.data(), eeprom.size()));
if (result.test(ALL_OK)) {
if (errors.test(HAS_WARNINGS)) {
// TODO ShowEepromWarnings(this, QObject::tr("Warning"), errors.to_ulong());
// TODO ShowEepromWarnings(this, CPN_STR_TTL_WARNING, errors.to_ulong());
}
board = eepromInterface->getBoard();
return true;
@@ -104,6 +104,6 @@ bool BinEepromFormat::extract(RadioData & radioData, const QByteArray & eeprom)
}
}
setError(QObject::tr("Invalid binary EEPROM file %1").arg(filename));
setError(tr("Invalid binary EEPROM file %1").arg(filename));
return false;
}
+7 -3
View File
@@ -23,18 +23,22 @@
#include "storage.h"
#include <QtCore>
class BinEepromFormat : public StorageFormat
{
Q_DECLARE_TR_FUNCTIONS(BinEepromFormat)
public:
BinEepromFormat(const QString & filename):
StorageFormat(filename)
{
}
virtual QString name() { return "bin"; };
virtual QString name() { return "bin"; }
virtual bool load(RadioData & radioData);
virtual bool write(const RadioData & radioData);
protected:
bool extract(RadioData & radioData, const QByteArray & eeprom);
virtual bool writeToFile(const uint8_t * eeprom, uint32_t size);
+4 -4
View File
@@ -25,7 +25,7 @@ bool CategorizedStorageFormat::load(RadioData & radioData)
{
QByteArray radioSettingsBuffer;
if (!loadFile(radioSettingsBuffer, "RADIO/radio.bin")) {
setError(QObject::tr("Can't extract RADIO/radio.bin"));
setError(tr("Can't extract RADIO/radio.bin"));
return false;
}
@@ -38,7 +38,7 @@ bool CategorizedStorageFormat::load(RadioData & radioData)
QByteArray modelsListBuffer;
if (!loadFile(modelsListBuffer, "RADIO/models.txt")) {
setError(QObject::tr("Can't extract RADIO/models.txt"));
setError(tr("Can't extract RADIO/models.txt"));
return false;
}
@@ -82,14 +82,14 @@ bool CategorizedStorageFormat::load(RadioData & radioData)
qDebug() << "Loading model from file" << fileName << "into slot" << modelIndex;
QByteArray modelBuffer;
if (!loadFile(modelBuffer, QString("MODELS/%1").arg(fileName))) {
setError(QObject::tr("Can't extract %1").arg(fileName));
setError(tr("Can't extract %1").arg(fileName));
return false;
}
if ((int)radioData.models.size() <= modelIndex) {
radioData.models.resize(modelIndex + 1);
}
if (!loadModelFromByteArray(radioData.models[modelIndex], modelBuffer)) {
setError(QObject::tr("Error loading models"));
setError(tr("Error loading models"));
return false;
}
strncpy(radioData.models[modelIndex].filename, qPrintable(fileName), sizeof(radioData.models[modelIndex].filename));
+5 -1
View File
@@ -23,14 +23,18 @@
#include "storage.h"
#include <QtCore>
class CategorizedStorageFormat : public StorageFormat
{
Q_DECLARE_TR_FUNCTIONS(CategorizedStorageFormat)
public:
CategorizedStorageFormat(const QString & filename):
StorageFormat(filename)
{
}
virtual bool load(RadioData & radioData);
virtual bool write(const RadioData & radioData);
+2 -2
View File
@@ -28,7 +28,7 @@ bool EepeFormat::load(RadioData & radioData)
QFile file(filename);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
setError(QObject::tr("Unable to open %1: %2").arg(filename).arg(file.errorString()));
setError(tr("Unable to open %1: %2").arg(filename).arg(file.errorString()));
return false;
}
@@ -44,7 +44,7 @@ bool EepeFormat::load(RadioData & radioData)
QByteArray eeprom(Boards::getEEpromSize(Board::BOARD_UNKNOWN), 0);
int eeprom_size = HexInterface(inputStream).load((uint8_t *)eeprom.data(), Boards::getEEpromSize(Board::BOARD_UNKNOWN));
if (!eeprom_size) {
setError(QObject::tr("Invalid EEPROM file %1").arg(filename));
setError(tr("Invalid EEPROM file %1").arg(filename));
return false;
}
eeprom.resize(eeprom_size);
+6 -2
View File
@@ -23,15 +23,19 @@
#include "hexeeprom.h"
#include <QtCore>
class EepeFormat : public HexEepromFormat
{
Q_DECLARE_TR_FUNCTIONS(EepeFormat)
public:
EepeFormat(const QString & filename):
HexEepromFormat(filename)
{
}
virtual QString name() { return "eepe"; };
virtual QString name() { return "eepe"; }
virtual bool load(RadioData & radioData);
};
+3 -3
View File
@@ -36,7 +36,7 @@ bool HexEepromFormat::load(RadioData & radioData)
QByteArray eeprom(Boards::getEEpromSize(Board::BOARD_UNKNOWN), 0);
int eeprom_size = HexInterface(inputStream).load((uint8_t *)eeprom.data(), Boards::getEEpromSize(Board::BOARD_UNKNOWN));
if (!eeprom_size) {
setError(QObject::tr("Invalid EEPROM File %1").arg(filename));
setError(tr("Invalid EEPROM File %1").arg(filename));
return false;
}
eeprom.resize(eeprom_size);
@@ -48,13 +48,13 @@ bool HexEepromFormat::writeToFile(const uint8_t * eeprom, uint32_t size)
{
QFile file(filename);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
setError(QObject::tr("Cannot open file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Cannot open file %1:\n%2.").arg(filename).arg(file.errorString()));
return false;
}
QTextStream outputStream(&file);
if (!HexInterface(outputStream).save(eeprom, size)) {
setError(QObject::tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
return false;
}
+7 -3
View File
@@ -23,17 +23,21 @@
#include "bineeprom.h"
#include <QtCore>
class HexEepromFormat : public BinEepromFormat
{
Q_DECLARE_TR_FUNCTIONS(HexEepromFormat)
public:
HexEepromFormat(const QString & filename):
BinEepromFormat(filename)
{
}
virtual QString name() { return "hex"; };
virtual QString name() { return "hex"; }
virtual bool load(RadioData & radioData);
protected:
virtual bool writeToFile(const uint8_t * eeprom, uint32_t size);
};
+16 -16
View File
@@ -27,23 +27,23 @@
bool OtxFormat::load(RadioData & radioData)
{
QFile file(filename);
if (!file.open(QFile::ReadOnly)) {
setError(QObject::tr("Error opening file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error opening file %1:\n%2.").arg(filename).arg(file.errorString()));
return false;
}
QByteArray archiveContents = file.readAll();
qDebug() << "File" << filename << "read, size:" << archiveContents.size();
// open zip file
memset(&zip_archive, 0, sizeof(zip_archive));
if (!mz_zip_reader_init_mem(&zip_archive, archiveContents.data(), archiveContents.size(), 0)) {
qDebug() << QObject::tr("Error opening OTX archive %1").arg(filename);
qDebug() << tr("Error opening OTX archive %1").arg(filename);
return false;
}
bool result = CategorizedStorageFormat::load(radioData);
mz_zip_reader_end(&zip_archive);
return result;
@@ -52,13 +52,13 @@ bool OtxFormat::load(RadioData & radioData)
bool OtxFormat::write(const RadioData & radioData)
{
qDebug() << "Saving to archive" << filename;
memset(&zip_archive, 0, sizeof(zip_archive));
if (!mz_zip_writer_init_heap(&zip_archive, 0, MZ_ALLOCATION_SIZE)) {
setError(QObject::tr("Error initializing OTX archive writer"));
setError(tr("Error initializing OTX archive writer"));
return false;
}
bool result = CategorizedStorageFormat::write(radioData);
if (result) {
// finalize archive and get contents
@@ -71,21 +71,21 @@ bool OtxFormat::write(const RadioData & radioData)
if (file.open(QIODevice::WriteOnly)) {
qint64 len = file.write(archiveContents, archiveSize);
if (len != (qint64)archiveSize) {
setError(QObject::tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error writing file %1:\n%2.").arg(filename).arg(file.errorString()));
result = false;
}
}
else {
setError(QObject::tr("Error creating OTX file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error creating OTX file %1:\n%2.").arg(filename).arg(file.errorString()));
result = false;
}
}
else {
setError(QObject::tr("Error creating OTX archive"));
setError(tr("Error creating OTX archive"));
result = false;
}
}
mz_zip_writer_end(&zip_archive);
return result;
}
@@ -108,9 +108,9 @@ bool OtxFormat::loadFile(QByteArray & filedata, const QString & filename)
bool OtxFormat::writeFile(const QByteArray & filedata, const QString & filename)
{
if (!mz_zip_writer_add_mem(&zip_archive, filename.toStdString().c_str(), filedata.data(), filedata.size(), MZ_DEFAULT_LEVEL)) {
setError(QObject::tr("Error adding %1 to OTX archive").arg(filename));
setError(tr("Error adding %1 to OTX archive").arg(filename));
return false;
}
return true;
}
+8 -4
View File
@@ -23,26 +23,30 @@
#include "categorized.h"
#include <QtCore>
#define MINIZ_HEADER_FILE_ONLY
#include "miniz.c"
#undef MINIZ_HEADER_FILE_ONLY
class OtxFormat : public CategorizedStorageFormat
{
Q_DECLARE_TR_FUNCTIONS(OtxFormat)
public:
OtxFormat(const QString & filename):
CategorizedStorageFormat(filename)
{
}
virtual QString name() { return "otx"; };
virtual QString name() { return "otx"; }
virtual bool load(RadioData & radioData);
virtual bool write(const RadioData & radioData);
protected:
virtual bool loadFile(QByteArray & fileData, const QString & fileName);
virtual bool writeFile(const QByteArray & fileData, const QString & fileName);
mz_zip_archive zip_archive;
};
+2 -2
View File
@@ -35,7 +35,7 @@ bool SdcardFormat::loadFile(QByteArray & filedata, const QString & filename)
QString path = this->filename + "/" + filename;
QFile file(path);
if (!file.open(QFile::ReadOnly)) {
setError(QObject::tr("Error opening file %1:\n%2.").arg(path).arg(file.errorString()));
setError(tr("Error opening file %1:\n%2.").arg(path).arg(file.errorString()));
return false;
}
filedata = file.readAll();
@@ -48,7 +48,7 @@ bool SdcardFormat::writeFile(const QByteArray & data, const QString & filename)
QString path = this->filename + "/" + filename;
QFile file(path);
if (!file.open(QFile::WriteOnly)) {
setError(QObject::tr("Error opening file %1 in write mode:\n%2.").arg(path).arg(file.errorString()));
setError(tr("Error opening file %1 in write mode:\n%2.").arg(path).arg(file.errorString()));
return false;
}
file.write(data.data(), data.size());
+8 -4
View File
@@ -23,17 +23,21 @@
#include "categorized.h"
#include <QtCore>
class SdcardFormat : public CategorizedStorageFormat
{
Q_DECLARE_TR_FUNCTIONS(SdcardFormat)
public:
SdcardFormat(const QString & filename):
CategorizedStorageFormat(filename)
{
}
virtual QString name() { return "sdcard"; };
virtual QString name() { return "sdcard"; }
virtual bool write(const RadioData & radioData);
protected:
virtual bool loadFile(QByteArray & fileData, const QString & fileName);
virtual bool writeFile(const QByteArray & fileData, const QString & fileName);
@@ -46,7 +50,7 @@ class SdcardStorageFactory : public DefaultStorageFactory<SdcardFormat>
DefaultStorageFactory<SdcardFormat>("sdcard")
{
}
virtual bool probe(const QString & name);
};
+1 -1
View File
@@ -74,7 +74,7 @@ bool Storage::load(RadioData & radioData)
{
QFile file(filename);
if (!file.exists()) {
setError(QObject::tr("Unable to find file %1!").arg(filename));
setError(tr("Unable to find file %1!").arg(filename));
return false;
}
+6
View File
@@ -22,6 +22,8 @@
#define _STORAGE_H_
#include "radiodata.h"
#include <QtCore>
#include <QString>
#include <QDebug>
@@ -41,6 +43,8 @@ StorageType getStorageType(const QString & filename);
class StorageFormat
{
Q_DECLARE_TR_FUNCTIONS(StorageFormat)
public:
StorageFormat(const QString & filename, uint8_t version=0):
filename(filename),
@@ -129,6 +133,8 @@ class DefaultStorageFactory : public StorageFactory
class Storage : public StorageFormat
{
Q_DECLARE_TR_FUNCTIONS(Storage)
public:
Storage(const QString & filename):
StorageFormat(filename)