Merge pull request #1044 from lexcibien/master
Adding translation to app and Portuguese Brazilian translation
This commit is contained in:
@@ -57,7 +57,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p SavvyCAN.app/Contents/MacOS/translations
|
||||||
mkdir -p SavvyCAN.app/Contents/MacOS/help
|
mkdir -p SavvyCAN.app/Contents/MacOS/help
|
||||||
|
cp -R translations/*.qm SavvyCAN.app/Contents/MacOS/translations
|
||||||
cp -R help/* SavvyCAN.app/Contents/MacOS/help
|
cp -R help/* SavvyCAN.app/Contents/MacOS/help
|
||||||
macdeployqt SavvyCAN.app -dmg
|
macdeployqt SavvyCAN.app -dmg
|
||||||
mv SavvyCAN.dmg SavvyCAN_x64.dmg
|
mv SavvyCAN.dmg SavvyCAN_x64.dmg
|
||||||
@@ -87,7 +89,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Package
|
- name: Package
|
||||||
run: |
|
run: |
|
||||||
|
mkdir -p SavvyCAN.app/Contents/MacOS/translations
|
||||||
mkdir -p SavvyCAN.app/Contents/MacOS/help
|
mkdir -p SavvyCAN.app/Contents/MacOS/help
|
||||||
|
cp -R translations/*.qm SavvyCAN.app/Contents/MacOS/translations
|
||||||
cp -R help/* SavvyCAN.app/Contents/MacOS/help
|
cp -R help/* SavvyCAN.app/Contents/MacOS/help
|
||||||
macdeployqt SavvyCAN.app -dmg
|
macdeployqt SavvyCAN.app -dmg
|
||||||
mv SavvyCAN.dmg SavvyCAN_arm64.dmg
|
mv SavvyCAN.dmg SavvyCAN_arm64.dmg
|
||||||
@@ -120,6 +124,7 @@ jobs:
|
|||||||
mkdir package
|
mkdir package
|
||||||
copy "release/SavvyCAN.exe" package/
|
copy "release/SavvyCAN.exe" package/
|
||||||
mkdir package/help
|
mkdir package/help
|
||||||
|
copy translations/*.qm package/translations/
|
||||||
copy help/*.md package/help/
|
copy help/*.md package/help/
|
||||||
mkdir package/help/images
|
mkdir package/help/images
|
||||||
copy help/images/*.* package/help/images/
|
copy help/images/*.* package/help/images/
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ build/
|
|||||||
*.o
|
*.o
|
||||||
*.obj
|
*.obj
|
||||||
|
|
||||||
|
# Compiled translations
|
||||||
|
*.qm
|
||||||
|
|
||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
*.pch
|
*.pch
|
||||||
@@ -36,6 +39,7 @@ SavvyCAN
|
|||||||
**/moc_*
|
**/moc_*
|
||||||
**/ui_*.h
|
**/ui_*.h
|
||||||
**/qrc_*.cpp
|
**/qrc_*.cpp
|
||||||
|
.qtc_clangd
|
||||||
SavvyCAN.pro.user.*
|
SavvyCAN.pro.user.*
|
||||||
.qmake.stash
|
.qmake.stash
|
||||||
Makefile
|
Makefile
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=SavvyCAN
|
Name=SavvyCAN
|
||||||
|
Name[pt_BR]=SavvyCAN
|
||||||
GenericName=CANBus reverse engineering tool
|
GenericName=CANBus reverse engineering tool
|
||||||
|
GenericName[pt_BR]=Ferramenta Rede CAN de engenharia reversa
|
||||||
Comment=Facilitates reverse engineering of canbus captures
|
Comment=Facilitates reverse engineering of canbus captures
|
||||||
|
Comment[pt_BR]=Facilitar engenharia reversa de capturas de Rede CAN
|
||||||
Exec=SavvyCAN
|
Exec=SavvyCAN
|
||||||
Icon=SavvyCAN
|
Icon=SavvyCAN
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Categories=Development;Electronics;IDE;
|
Categories=Development;Electronics;IDE;
|
||||||
MimeType=text/x-application;
|
MimeType=text/x-application;
|
||||||
Keywords=embedded electronics;electronics;canbus;reverse engineering;
|
Keywords=embedded electronics;electronics;canbus;reverse engineering;
|
||||||
|
Keywords[pt_BR]=eletronica embarcada;eletronicos;canbus;engenharia reversa;
|
||||||
|
|||||||
@@ -279,3 +279,9 @@ INSTALLS += helpfiles
|
|||||||
|
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
|
TRANSLATIONS += \
|
||||||
|
translations/SavvyCAN_en.ts \
|
||||||
|
translations/SavvyCAN_pt_BR.ts
|
||||||
|
|
||||||
|
DISTFILES += \
|
||||||
|
translations/pt_BR.qph
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class SavvyCANApplication : public QApplication
|
class SavvyCANApplication : public QApplication
|
||||||
{
|
{
|
||||||
@@ -39,11 +42,31 @@ int main(int argc, char *argv[])
|
|||||||
a.setOrganizationName("EVTV");
|
a.setOrganizationName("EVTV");
|
||||||
a.setApplicationName("SavvyCAN");
|
a.setApplicationName("SavvyCAN");
|
||||||
a.setOrganizationDomain("evtv.me");
|
a.setOrganizationDomain("evtv.me");
|
||||||
|
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
QString localeString = settings.value("Main/Language").toString();
|
||||||
|
if (localeString.isEmpty()) {
|
||||||
|
QLocale sysLocale = QLocale::system();
|
||||||
|
localeString = sysLocale.name();
|
||||||
|
settings.setValue("Main/Language", localeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTranslator translator;
|
||||||
|
QLocale locale(localeString);
|
||||||
|
QString lang = locale.name();
|
||||||
|
QString shortLang = locale.name().left(2);
|
||||||
|
|
||||||
|
if (QString translationDir = QCoreApplication::applicationDirPath() + "/translations"; !translator.load("SavvyCAN_" + lang, translationDir)) {
|
||||||
|
translator.load("SavvyCAN_" + shortLang, translationDir);
|
||||||
|
}
|
||||||
|
a.installTranslator(&translator);
|
||||||
|
|
||||||
|
qInfo() << "Locale Value is:" << locale.name();
|
||||||
|
|
||||||
a.mainWindow = new MainWindow();
|
a.mainWindow = new MainWindow();
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
int fontSize = settings.value("Main/FontSize", 9).toUInt();
|
int fontSize = settings.value("Main/FontSize", 9).toUInt();
|
||||||
QFont sysFont = QFont(); //get default font
|
QFont sysFont = QFont(); //get default font
|
||||||
sysFont.setPointSize(fontSize);
|
sysFont.setPointSize(fontSize);
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
#include "helpwindow.h"
|
#include "helpwindow.h"
|
||||||
#include <qevent.h>
|
#include <qevent.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QRegExp>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
#include "simplecrypt.h"
|
#include "simplecrypt.h"
|
||||||
|
|
||||||
//using this simple encryption library to obfuscate stored password a bit. It's not super secure but better than
|
//using this simple encryption library to obfuscate stored password a bit. It's not super secure but better than
|
||||||
@@ -10,6 +14,42 @@
|
|||||||
//whatever key, you'd see it. Just behave yourselves
|
//whatever key, you'd see it. Just behave yourselves
|
||||||
SimpleCrypt crypto(Q_UINT64_C(0xdeadbeefface6285));
|
SimpleCrypt crypto(Q_UINT64_C(0xdeadbeefface6285));
|
||||||
|
|
||||||
|
static QStringList availableLanguageCodes()
|
||||||
|
{
|
||||||
|
QStringList codes;
|
||||||
|
QDir transDir(QCoreApplication::applicationDirPath() + "/translations");
|
||||||
|
QStringList list = transDir.entryList(QStringList() << "SavvyCAN_*.qm");
|
||||||
|
//* just for test purposes
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
// maybe only ts files exist during development
|
||||||
|
list = transDir.entryList(QStringList() << "SavvyCAN_*.ts");
|
||||||
|
}
|
||||||
|
for (QString file : list) {
|
||||||
|
QRegExp re("SavvyCAN_(.*)\\.(qm|ts)");
|
||||||
|
if (re.indexIn(file) != -1) {
|
||||||
|
codes << re.cap(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return codes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainSettingsDialog::populateLanguageCombo()
|
||||||
|
{
|
||||||
|
ui->comboLanguage->clear();
|
||||||
|
QStringList codes = availableLanguageCodes();
|
||||||
|
if (codes.isEmpty()) {
|
||||||
|
codes << "en"; // fallback
|
||||||
|
}
|
||||||
|
for (const QString &code : codes) {
|
||||||
|
QLocale locale(code);
|
||||||
|
QString name = locale.nativeLanguageName();
|
||||||
|
qInfo() << code;
|
||||||
|
if (name.isEmpty())
|
||||||
|
name = code;
|
||||||
|
ui->comboLanguage->addItem(name, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::MainSettingsDialog)
|
ui(new Ui::MainSettingsDialog)
|
||||||
@@ -17,6 +57,8 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
populateLanguageCombo();
|
||||||
|
|
||||||
//TODO: This is still hard coded to support only two buses. Sometimes there is none, sometimes 1, sometimes much more than 2. Fix this.
|
//TODO: This is still hard coded to support only two buses. Sometimes there is none, sometimes 1, sometimes much more than 2. Fix this.
|
||||||
ui->comboSendingBus->addItem(tr("None"));
|
ui->comboSendingBus->addItem(tr("None"));
|
||||||
ui->comboSendingBus->addItem(tr("0"));
|
ui->comboSendingBus->addItem(tr("0"));
|
||||||
@@ -94,6 +136,12 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
|||||||
ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool());
|
ui->cbIgnoreDBCColors->setChecked(settings.value("Main/IgnoreDBCColors", false).toBool());
|
||||||
ui->cbColorsByCanId->setChecked(settings.value("Main/ColorsByCanId", false).toBool());
|
ui->cbColorsByCanId->setChecked(settings.value("Main/ColorsByCanId", false).toBool());
|
||||||
|
|
||||||
|
if (QString savedLang = settings.value("Main/Language").toString(); !savedLang.isEmpty()) {
|
||||||
|
int idx = ui->comboLanguage->findData(savedLang);
|
||||||
|
if (idx >= 0)
|
||||||
|
ui->comboLanguage->setCurrentIndex(idx);
|
||||||
|
}
|
||||||
|
|
||||||
int maxFramesDefault;
|
int maxFramesDefault;
|
||||||
if (QSysInfo::WordSize > 32)
|
if (QSysInfo::WordSize > 32)
|
||||||
{
|
{
|
||||||
@@ -110,6 +158,7 @@ MainSettingsDialog::MainSettingsDialog(QWidget *parent) :
|
|||||||
ui->spinBytesPerLine->setValue(settings.value("Main/BytesPerLine", 8).toInt());
|
ui->spinBytesPerLine->setValue(settings.value("Main/BytesPerLine", 8).toInt());
|
||||||
|
|
||||||
//just for simplicity they all call the same function and that function updates all settings at once
|
//just for simplicity they all call the same function and that function updates all settings at once
|
||||||
|
connect(ui->comboLanguage, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSettings()));
|
||||||
connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
connect(ui->cbDisplayHex, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||||
connect(ui->cbFlowAutoRef, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
connect(ui->cbFlowAutoRef, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||||
connect(ui->cbFlowUseTimestamp, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
connect(ui->cbFlowUseTimestamp, SIGNAL(toggled(bool)), this, SLOT(updateSettings()));
|
||||||
@@ -179,6 +228,7 @@ void MainSettingsDialog::updateSettings()
|
|||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.setValue("Main/Language", ui->comboLanguage->currentData().toString());
|
||||||
settings.setValue("Main/UseHex", ui->cbDisplayHex->isChecked());
|
settings.setValue("Main/UseHex", ui->cbDisplayHex->isChecked());
|
||||||
settings.setValue("FlowView/AutoRef", ui->cbFlowAutoRef->isChecked());
|
settings.setValue("FlowView/AutoRef", ui->cbFlowAutoRef->isChecked());
|
||||||
settings.setValue("FlowView/UseTimestamp", ui->cbFlowUseTimestamp->isChecked());
|
settings.setValue("FlowView/UseTimestamp", ui->cbFlowUseTimestamp->isChecked());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
Ui::MainSettingsDialog *ui;
|
Ui::MainSettingsDialog *ui;
|
||||||
|
|
||||||
|
void populateLanguageCombo();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
bool eventFilter(QObject *obj, QEvent *event);
|
bool eventFilter(QObject *obj, QEvent *event);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Scripts
|
||||||
|
|
||||||
|
To run this scripts, first you must authorize your terminal to run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x script/*.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can run by using this command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/the/script/you/want/to/run
|
||||||
|
```
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROJECT_ROOT="$(pwd)"
|
||||||
|
|
||||||
|
# To add this tool in Qt Creator:
|
||||||
|
# Category: Linguist
|
||||||
|
# Name: Release Translations (lrelease)
|
||||||
|
# Executable: lrelease
|
||||||
|
# Arguments: SavvyCAN.pro
|
||||||
|
# Working Directory: %{ActiveProject:Path}
|
||||||
|
|
||||||
|
echo "Generating .qm files..."
|
||||||
|
|
||||||
|
lrelease -verbose "$PROJECT_ROOT"/SavvyCAN.pro
|
||||||
|
|
||||||
|
echo ".qm files generated."
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PROJECT_ROOT="$(pwd)"
|
||||||
|
|
||||||
|
# To add this tool in Qt Creator:
|
||||||
|
# Category: Linguist
|
||||||
|
# Name: Update Translations (lupdate)
|
||||||
|
# Executable: lupdate
|
||||||
|
# Arguments: -project SavvyCAN.pro
|
||||||
|
# Working Directory: %{ActiveProject:Path}
|
||||||
|
|
||||||
|
echo "Updating translation files..."
|
||||||
|
|
||||||
|
lupdate -verbose "$PROJECT_ROOT"/SavvyCAN.pro
|
||||||
|
|
||||||
|
echo "Translation files updated."
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
|||||||
|
<!DOCTYPE QPH>
|
||||||
|
<QPH sourcelanguage="en" language="pt_BR">
|
||||||
|
<phrase>
|
||||||
|
<source>New</source>
|
||||||
|
<target>Novo</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Save</source>
|
||||||
|
<target>Salvar</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Cancel</source>
|
||||||
|
<target>Cancelar</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Connect</source>
|
||||||
|
<target>Conectar</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Disconnect</source>
|
||||||
|
<target>Desconectar</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Yes</source>
|
||||||
|
<target>Sim</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>No</source>
|
||||||
|
<target>Não</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Bus</source>
|
||||||
|
<target>Barramento</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Frame</source>
|
||||||
|
<target>Frame</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Frames</source>
|
||||||
|
<target>Frames</target>
|
||||||
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
<source>Scan</source>
|
||||||
|
<target>Varredura</target>
|
||||||
|
</phrase>
|
||||||
|
</QPH>
|
||||||
@@ -53,6 +53,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="text">
|
||||||
|
<string>Language</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboLanguage"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user