A system of translations into different languages has been implemented. Added translations into Russian. Various UI fixes for valid internationalization

This commit is contained in:
Yury Shuvakin
2022-08-28 11:33:56 +03:00
parent 2a960893d0
commit 4a0f78c247
39 changed files with 3365 additions and 357 deletions

View File

@@ -89,8 +89,11 @@ BMSInterface::BMSInterface(QObject *parent) : QObject(parent)
// BLE
#ifdef HAS_BLUETOOTH
mBleUart = new BleUart(this);
mLastBleAddr = QSettings().value("ble_addr").toString();
connect(mBleUart, SIGNAL(dataRx(QByteArray)), this, SLOT(bleDataRx(QByteArray)));
#endif
int size = mSettings.beginReadArray("bleNames");
for (int i = 0; i < size; ++i) {
@@ -101,8 +104,6 @@ BMSInterface::BMSInterface(QObject *parent) : QObject(parent)
}
mSettings.endArray();
connect(mBleUart, SIGNAL(dataRx(QByteArray)), this, SLOT(bleDataRx(QByteArray)));
mCommands->setbmsConfig(mbmsConfig);
// Other signals/slots
@@ -280,9 +281,11 @@ bool BMSInterface::isPortConnected()
res = true;
}
#ifdef HAS_BLUETOOTH
if (mBleUart->isConnected()) {
res = true;
}
#endif
return res;
}
@@ -301,10 +304,12 @@ void BMSInterface::disconnectPort()
updateFwRx(false);
}
#ifdef HAS_BLUETOOTH
if (mBleUart->isConnected()) {
mBleUart->disconnectBle();
updateFwRx(false);
}
#endif
mFwRetries = 0;
}
@@ -321,8 +326,12 @@ bool BMSInterface::reconnectLastPort()
connectTcp(mLastTcpServer, mLastTcpPort);
return true;
} else if (mLastConnType == CONN_BLE) {
#ifdef HAS_BLUETOOTH
mBleUart->startConnect(mLastBleAddr);
return true;
#else
return false;
#endif
} else {
#ifdef HAS_SERIALPORT
QList<VSerialInfo_t> ports = listSerialPorts();
@@ -408,10 +417,12 @@ QString BMSInterface::getConnectedPortName()
connected = true;
}
#ifdef HAS_BLUETOOTH
if (mBleUart->isConnected()) {
res = tr("Connected (BLE) to %1").arg(mLastBleAddr);
connected = true;
}
#endif
if (connected && mCommands->isLimitedMode()) {
res += tr(", limited mode");
@@ -551,10 +562,12 @@ void BMSInterface::connectTcp(QString server, int port)
void BMSInterface::connectBle(QString address)
{
#ifdef HAS_BLUETOOTH
mBleUart->startConnect(address);
mLastConnType = CONN_BLE;
mLastBleAddr = address;
setLastConnectionType(CONN_BLE);
#endif
}
bool BMSInterface::isAutoconnectOngoing() const
@@ -629,7 +642,7 @@ void BMSInterface::serialPortError(QSerialPort::SerialPortError error)
break;
default:
message = "Serial port error: " + mSerialPort->errorString();
message = tr("Serial port error: ") + mSerialPort->errorString();
break;
}
@@ -762,9 +775,11 @@ void BMSInterface::packetDataToSend(QByteArray &data)
mTcpSocket->write(data);
}
#ifdef HAS_BLUETOOTH
if (mBleUart->isConnected()) {
mBleUart->writeData(data);
}
#endif
}
void BMSInterface::packetReceived(QByteArray &data)
@@ -846,15 +861,17 @@ void BMSInterface::fwVersionReceived(int major, int minor, QString hw, QByteArra
}
}
QString fwStr;
fwStr.sprintf("ENNOID-BMS Firmware Version %d.%d", major, minor);
if (!hw.isEmpty()) {
fwStr += ", Hardware: " + hw;
}
auto fwStr = tr("Firmware version: %1.%2, Hardware: %3, UUID: %4").arg(major).arg(minor).arg(hw).arg(strUuid);
if (!strUuid.isEmpty()) {
fwStr += ", UUID: " + strUuid;
}
// QString fwStr;
// fwStr.sprintf("ENNOID-BMS Firmware Version %d.%d", major, minor);
// if (!hw.isEmpty()) {
// fwStr += ", Hardware: " + hw;
// }
// if (!strUuid.isEmpty()) {
// fwStr += ", UUID: " + strUuid;
// }
emit statusMessage(fwStr, true);
#if 0