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:
2024-11-05 13:49:00 +03:00
parent 73ed51e3d4
commit 57f8c1313e
52 changed files with 1571 additions and 480 deletions

View File

@@ -24,6 +24,7 @@
#include "piincludes_p.h"
#include "pipropertystorage.h"
#include "pitime.h"
#include "pitranslator.h"
#include "piwaitevent_p.h"
#include <errno.h>
@@ -463,10 +464,10 @@ int PISerial::convertSpeed(PISerial::Speed speed) {
default: break;
}
#ifdef WINDOWS
piCoutObj << "Warning: Custom speed" << (int)speed;
piCoutObj << "Warning: Custom speed %1"_tr("PISerial").arg((int)speed);
return (int)speed;
#else
piCoutObj << "Warning: Unknown speed" << (int)speed << ", using 115200";
piCoutObj << "Warning: Unknown speed %1, using 115200"_tr("PISerial").arg((int)speed);
return B115200;
#endif
}
@@ -691,7 +692,7 @@ bool PISerial::openDevice() {
}
}
if (p.isEmpty()) {
piCoutObj << "Unable to find device \"" << pl << "\"";
piCoutObj << "Unable to find device \"%1\""_tr("PISerial").arg(pl);
}
}
if (p.isEmpty()) return false;
@@ -708,7 +709,7 @@ bool PISerial::openDevice() {
PIString wp = "//./" + p;
PRIVATE->hCom = CreateFileA(wp.dataAscii(), ds, sm, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
if (PRIVATE->hCom == INVALID_HANDLE_VALUE) {
piCoutObj << "Unable to open \"" << p << "\"" << errorString();
piCoutObj << "Unable to open \"%1\": %2"_tr("PISerial").arg(p).arg(errorString());
fd = -1;
return false;
}
@@ -722,7 +723,7 @@ bool PISerial::openDevice() {
}
fd = ::open(p.data(), O_NOCTTY | om);
if (fd == -1) {
piCoutObj << "Unable to open \"" << p << "\"";
piCoutObj << "Unable to open \"%1\": %2"_tr("PISerial").arg(p).arg(errorString());
return false;
}
tcgetattr(fd, &PRIVATE->desc);
@@ -747,7 +748,7 @@ bool PISerial::closeDevice() {
#ifdef WINDOWS
SetCommState(PRIVATE->hCom, &PRIVATE->sdesc);
SetCommMask(PRIVATE->hCom, PRIVATE->mask);
// piCoutObj << "close" <<
// piCoutObj << "close" <<
CloseHandle(PRIVATE->hCom);
PRIVATE->hCom = 0;
#else
@@ -788,7 +789,7 @@ void PISerial::applySettings() {
}
PRIVATE->desc.StopBits = params[PISerial::TwoStopBits] ? TWOSTOPBITS : ONESTOPBIT;
if (SetCommState(PRIVATE->hCom, &PRIVATE->desc) == -1) {
piCoutObj << "Unable to set comm state for \"" << path() << "\"";
piCoutObj << "Unable to set comm state for \"%1\""_tr("PISerial").arg(path());
return;
}
#else
@@ -822,7 +823,7 @@ void PISerial::applySettings() {
setTimeouts();
if (tcsetattr(fd, TCSANOW, &PRIVATE->desc) < 0) {
piCoutObj << "Can`t set attributes for \"" << path() << "\"";
piCoutObj << "Can`t set attributes for \"%1\""_tr("PISerial").arg(path());
return;
}
#endif
@@ -871,7 +872,7 @@ ssize_t PISerial::readDevice(void * read_to, ssize_t max_size) {
// piCoutObj << "read ..." << PRIVATE->hCom << max_size;
DWORD mask = 0;
if (GetCommMask(PRIVATE->hCom, &mask) == FALSE) {
piCoutObj << "read error" << errorString();
piCoutObj << "Read error: %1"_tr("PISerial").arg(errorString());
stop();
close();
return 0;
@@ -883,7 +884,7 @@ ssize_t PISerial::readDevice(void * read_to, ssize_t max_size) {
DWORD err = GetLastError();
// piCoutObj << "read" << err;
if (err == ERROR_BAD_COMMAND || err == ERROR_ACCESS_DENIED) {
piCoutObj << "read error" << errorString();
piCoutObj << "Read error: %1"_tr("PISerial").arg(errorString());
stop();
close();
return 0;