first release of translation facility
* runtime - loading and translating * design-time - works with *.ts file (pip_tr utility) * compile-time - CMake macro for compile *.ts
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "piliterals_time.h"
|
||||
#include "pipropertystorage.h"
|
||||
#include "pitime.h"
|
||||
#include "pitranslator.h"
|
||||
|
||||
#define PIBINARYLOG_VERSION_OLD 0x31
|
||||
|
||||
@@ -100,7 +101,7 @@ bool PIBinaryLog::openDevice() {
|
||||
index.clear();
|
||||
log_size = 0;
|
||||
if (mode_ == ReadWrite) {
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly";
|
||||
piCoutObj << "Error: ReadWrite mode not supported, use WriteOnly or ReadOnly"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
if (path().isEmpty() && mode_ == WriteOnly) {
|
||||
@@ -122,21 +123,21 @@ bool PIBinaryLog::openDevice() {
|
||||
}
|
||||
}
|
||||
if (!file.open(path(), mode_)) {
|
||||
piCoutObj << "Error: Can't open file" << path();
|
||||
piCoutObj << "Error: Can't open file \"%1\": %2"_tr("PIBinLog").arg(path()).arg(errorString());
|
||||
return false;
|
||||
}
|
||||
setName(path());
|
||||
if (mode_ == WriteOnly) {
|
||||
file.clear();
|
||||
if (!writeFileHeader()) {
|
||||
piCoutObj << "Error: Can't write binlog file header" << path();
|
||||
piCoutObj << "Error: Can't write binlog file header \"%1\""_tr("PIBinLog").arg(path());
|
||||
return false;
|
||||
}
|
||||
is_started = true;
|
||||
}
|
||||
if (mode_ == ReadOnly) {
|
||||
if (file.isEmpty()) {
|
||||
piCoutObj << "Error: File is null" << path();
|
||||
piCoutObj << "Error: File is null \"%1\""_tr("PIBinLog").arg(path());
|
||||
fileError();
|
||||
return false;
|
||||
}
|
||||
@@ -145,7 +146,7 @@ bool PIBinaryLog::openDevice() {
|
||||
return false;
|
||||
}
|
||||
if (isEmpty()) {
|
||||
piCoutObj << "Warning: Empty BinLog file" << path();
|
||||
piCoutObj << "Warning: Empty BinLog file \"%1\""_tr("PIBinLog").arg(path());
|
||||
fileEnd();
|
||||
}
|
||||
play_time = 0;
|
||||
@@ -175,7 +176,7 @@ bool PIBinaryLog::closeDevice() {
|
||||
|
||||
|
||||
bool PIBinaryLog::threadedRead(const uchar * readed, ssize_t size) {
|
||||
// piCout << "binlog threaded read";
|
||||
// piCout << "binlog threaded read";
|
||||
if (!canRead() || isEnd()) return PIIODevice::threadedRead(readed, size);
|
||||
is_thread_ok = false;
|
||||
logmutex.lock();
|
||||
@@ -258,7 +259,7 @@ PIString PIBinaryLog::getLogfilePath(const PIString & log_dir, const PIString &
|
||||
dir.setDir(dir.absolutePath());
|
||||
if (!dir.isExists()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Creating directory" << dir.path();
|
||||
<< "Creating directory \"%1\""_tr("PIBinLog").arg(dir.path());
|
||||
dir.make(true);
|
||||
}
|
||||
const PIString npath = log_dir + PIDir::separator + prefix + PIDateTime::current().toString("yyyy_MM_dd__hh_mm_ss");
|
||||
@@ -282,7 +283,7 @@ PIString PIBinaryLog::createNewFile() {
|
||||
newFile(file.path());
|
||||
return file.path();
|
||||
}
|
||||
piCoutObj << "Can't create new file, maybe LogDir" << ("\"" + logDir() + "\"") << "is invalid.";
|
||||
piCoutObj << "Can't create new file, maybe LogDir \"%1\" is invalid"_tr("PIBinLog").arg(logDir());
|
||||
return PIString();
|
||||
}
|
||||
|
||||
@@ -291,7 +292,7 @@ void PIBinaryLog::createNewFile(const PIString & path) {
|
||||
if (open(path, PIIODevice::WriteOnly)) {
|
||||
newFile(file.path());
|
||||
} else
|
||||
piCoutObj << "Can't create new file, maybe path" << ("\"" + path + "\"") << "is invalid.";
|
||||
piCoutObj << "Can't create new file, maybe path \"%1\" is invalid"_tr("PIBinLog").arg(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -315,7 +316,7 @@ void PIBinaryLog::setPause(bool pause) {
|
||||
int PIBinaryLog::writeBinLog(int id, const void * data, int size) {
|
||||
if (size <= 0 || !canWrite()) return -1;
|
||||
if (id == 0) {
|
||||
piCoutObj << "Error: can`t write with id = 0! Id must be > 0";
|
||||
piCoutObj << "Error: can`t write with id = 0! ID must be > 0"_tr("PIBinLog");
|
||||
return -1;
|
||||
}
|
||||
if (is_pause) return 0;
|
||||
@@ -359,7 +360,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
Record br = readRecord();
|
||||
logmutex.unlock();
|
||||
if (br.id == -1) {
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
fileEnd();
|
||||
return PIByteArray();
|
||||
}
|
||||
@@ -373,7 +374,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
br = readRecord();
|
||||
logmutex.unlock();
|
||||
if (br.id == -1) {
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
fileEnd();
|
||||
return PIByteArray();
|
||||
}
|
||||
@@ -382,7 +383,7 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
|
||||
if (readed_id) *readed_id = br.id;
|
||||
return br.data;
|
||||
}
|
||||
piCoutObj << "Can't find record with id =" << id;
|
||||
piCoutObj << "Can't find record with id = %1"_tr("PIBinLog").arg(id);
|
||||
return PIByteArray();
|
||||
}
|
||||
|
||||
@@ -428,15 +429,15 @@ ssize_t PIBinaryLog::readDevice(void * read_to, ssize_t max_size) {
|
||||
}
|
||||
if (br.id == -1) {
|
||||
fileEnd();
|
||||
piCoutObj << "End of BinLog file";
|
||||
piCoutObj << "End of BinLog file"_tr("PIBinLog");
|
||||
return 0;
|
||||
}
|
||||
if (br.id == 0) {
|
||||
piCoutObj << "Read record error";
|
||||
piCoutObj << "Read record error"_tr("PIBinLog");
|
||||
return -1;
|
||||
}
|
||||
const ssize_t sz = piMini(max_size, br.data.size());
|
||||
if (sz < br.data.size_s()) piCoutObj << "too small read buffer:" << max_size << ", data size:" << br.data.size();
|
||||
if (sz < br.data.size_s()) piCoutObj << "too small read buffer: %1, data size: %2"_tr("PIBinLog").arg(max_size).arg(br.data.size());
|
||||
memcpy(read_to, br.data.data(), sz);
|
||||
return sz;
|
||||
}
|
||||
@@ -491,7 +492,7 @@ bool PIBinaryLog::checkFileHeader() {
|
||||
for (uint i = 0; i < PIBINARYLOG_SIGNATURE_SIZE; i++)
|
||||
if (read_sig[i] != binlog_sig[i]) correct = false;
|
||||
if (!correct) {
|
||||
piCoutObj << "BinLogFile signature is corrupted or invalid file";
|
||||
piCoutObj << "BinLogFile signature is corrupted or invalid file"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
uchar read_version = 0;
|
||||
@@ -509,9 +510,9 @@ bool PIBinaryLog::checkFileHeader() {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (read_version == 0) piCoutObj << "BinLogFile has invalid version";
|
||||
if (read_version < PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too old verion";
|
||||
if (read_version > PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too newest version";
|
||||
if (read_version == 0) piCoutObj << "BinLogFile has invalid version"_tr("PIBinLog");
|
||||
if (read_version < PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too old verion"_tr("PIBinLog");
|
||||
if (read_version > PIBINARYLOG_VERSION) piCoutObj << "BinLogFile has too new version"_tr("PIBinLog");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -545,7 +546,7 @@ PIBinaryLog::Record PIBinaryLog::readRecord() {
|
||||
if (br.id == 0) fileError();
|
||||
moveIndex(index.index_pos.value(file.pos(), -1));
|
||||
logmutex.unlock();
|
||||
// piCoutObj << "readRecord done";
|
||||
// piCoutObj << "readRecord done";
|
||||
return br;
|
||||
}
|
||||
|
||||
@@ -721,7 +722,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
PIBinaryLog slog;
|
||||
if (!slog.open(src.path, PIIODevice::ReadOnly)) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't open" << src.path;
|
||||
<< "Error, can't open \"%1\""_tr("PIBinLog").arg(src.path);
|
||||
return false;
|
||||
}
|
||||
const PIVector<int> ids = src.records.keys();
|
||||
@@ -730,7 +731,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
dlog.createNewFile(dst);
|
||||
if (!dlog.isOpened()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't create" << dst;
|
||||
<< "Error, can't create \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
bool first = true;
|
||||
@@ -746,7 +747,7 @@ bool PIBinaryLog::cutBinLog(const PIBinaryLog::BinLogInfo & src, const PIString
|
||||
if (ids.contains(br.id)) {
|
||||
if (dlog.writeBinLog_raw(br.id, br.timestamp - st, br.data) <= 0) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't write to file" << dst;
|
||||
<< "Error, can't write to file \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -772,7 +773,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
for (const PIString & fn: src) {
|
||||
if (!slog.open(fn, PIIODevice::ReadOnly)) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't open" << fn;
|
||||
<< "Error, can't open \"%1\""_tr("PIBinLog").arg(fn);
|
||||
return false;
|
||||
}
|
||||
if (first) {
|
||||
@@ -781,11 +782,11 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
dlog.createNewFile(dst);
|
||||
if (!dlog.isOpened()) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't create" << dst;
|
||||
<< "Error, can't create \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Start join binlogs to" << dst;
|
||||
<< "Start join binlogs to \"%1\""_tr("PIBinLog").arg(dst);
|
||||
} else {
|
||||
dtime = lt;
|
||||
}
|
||||
@@ -799,7 +800,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
lt = dtime + br.timestamp;
|
||||
if (dlog.writeBinLog_raw(br.id, lt, br.data) <= 0) {
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Error, can't write to file" << dst;
|
||||
<< "Error, can't write to file \"%1\""_tr("PIBinLog").arg(dst);
|
||||
return false;
|
||||
}
|
||||
if (tm.elapsed_s() > 0.1) {
|
||||
@@ -821,7 +822,7 @@ bool PIBinaryLog::joinBinLogsSerial(const PIStringList & src,
|
||||
// piCout << "[PIBinaryLog]" << "complete" << fn;
|
||||
}
|
||||
piCout << "[PIBinaryLog]"
|
||||
<< "Finish join binlogs, total time" << PITime::fromSystemTime(lt).toString();
|
||||
<< "Finish join binlogs, total time %1"_tr("PIBinLog").arg(PITime::fromSystemTime(lt).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -853,7 +854,7 @@ int PIBinaryLog::posForTime(const PISystemTime & time) {
|
||||
|
||||
|
||||
void PIBinaryLog::seekTo(int rindex) {
|
||||
// piCoutObj << "seekTo";
|
||||
// piCoutObj << "seekTo";
|
||||
logmutex.lock();
|
||||
pausemutex.lock();
|
||||
if (rindex < index.index.size_s() && rindex >= 0) {
|
||||
@@ -866,7 +867,7 @@ void PIBinaryLog::seekTo(int rindex) {
|
||||
startlogtime = PISystemTime::current() - lastrecord.timestamp;
|
||||
}
|
||||
}
|
||||
// piCoutObj << "seekTo done";
|
||||
// piCoutObj << "seekTo done";
|
||||
pausemutex.unlock();
|
||||
logmutex.unlock();
|
||||
}
|
||||
@@ -947,7 +948,7 @@ void PIBinaryLog::configureFromFullPathDevice(const PIString & full_path) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// piCoutObj << "configured";
|
||||
// piCoutObj << "configured";
|
||||
}
|
||||
|
||||
|
||||
@@ -989,7 +990,7 @@ void PIBinaryLog::propertyChanged(const char * s) {
|
||||
split_time = property("splitTime").toSystemTime();
|
||||
split_size = property("splitFileSize").toLLong();
|
||||
split_count = property("splitRecordCount").toInt();
|
||||
// piCoutObj << "propertyChanged" << s << play_mode;
|
||||
// piCoutObj << "propertyChanged" << s << play_mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user