mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Added translations (#848)
This commit is contained in:
parent
ec254b1d24
commit
dd4a566408
@ -15,6 +15,14 @@ SET "BUILDDIR=build_%PLATFORM%"
|
|||||||
ECHO Preparing directory
|
ECHO Preparing directory
|
||||||
RMDIR /S /Q %BUILDDIR%
|
RMDIR /S /Q %BUILDDIR%
|
||||||
MKDIR %BUILDDIR%
|
MKDIR %BUILDDIR%
|
||||||
|
|
||||||
|
ECHO Prepare translations
|
||||||
|
lrelease.exe ..\src\cutter.pro
|
||||||
|
|
||||||
|
RMDIR /S /Q %BUILDDIR%\translations
|
||||||
|
MKDIR %BUILDDIR%\translations
|
||||||
|
FOR %%i in (src\translations\*.qm) DO MOVE "%%~fi" "%CD%\%BUILDDIR%\translations"
|
||||||
|
|
||||||
CD %BUILDDIR%
|
CD %BUILDDIR%
|
||||||
|
|
||||||
ECHO Building cutter
|
ECHO Building cutter
|
||||||
|
11
build.sh
11
build.sh
@ -9,8 +9,12 @@ ERR=0
|
|||||||
#### User variables ####
|
#### User variables ####
|
||||||
BUILD="build"
|
BUILD="build"
|
||||||
QMAKE_CONF=""
|
QMAKE_CONF=""
|
||||||
|
ROOT_DIR=`pwd`
|
||||||
#QMAKE_CONF="CUTTER_ENABLE_JUPYTER=false CUTTER_ENABLE_QTWEBENGINE=false"
|
#QMAKE_CONF="CUTTER_ENABLE_JUPYTER=false CUTTER_ENABLE_QTWEBENGINE=false"
|
||||||
|
|
||||||
|
# Create translations
|
||||||
|
lrelease ./src/Cutter.pro
|
||||||
|
|
||||||
# Checking for radare2
|
# Checking for radare2
|
||||||
r2 -v >/dev/null 2>&1
|
r2 -v >/dev/null 2>&1
|
||||||
if [ $? = 0 ]; then
|
if [ $? = 0 ]; then
|
||||||
@ -56,6 +60,13 @@ cd "$BUILD" || exit 1
|
|||||||
"$qmakepath" "$QMAKE_CONF" ../src/Cutter.pro
|
"$qmakepath" "$QMAKE_CONF" ../src/Cutter.pro
|
||||||
make -j4
|
make -j4
|
||||||
ERR=$((ERR+$?))
|
ERR=$((ERR+$?))
|
||||||
|
|
||||||
|
# Move translations
|
||||||
|
mkdir "`pwd`/translations"
|
||||||
|
find "$ROOT_DIR/src/translations" -maxdepth 1 -type f | grep "cutter_..\.qm" | while read SRC_FILE; do
|
||||||
|
mv $SRC_FILE "`pwd`/translations"
|
||||||
|
done
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
@ -11,6 +11,13 @@ VERSION = $${CUTTER_VERSION_MAJOR}.$${CUTTER_VERSION_MINOR}.$${CUTTER_VERSION_PA
|
|||||||
# Required QT version
|
# Required QT version
|
||||||
lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5")
|
lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5")
|
||||||
|
|
||||||
|
TRANSLATIONS += translations/cutter_de.ts \
|
||||||
|
translations/cutter_es.ts \
|
||||||
|
translations/cutter_fr.ts \
|
||||||
|
translations/cutter_it.ts \
|
||||||
|
translations/cutter_nl.ts \
|
||||||
|
translations/cutter_ru.ts
|
||||||
|
|
||||||
# Icon for OS X
|
# Icon for OS X
|
||||||
ICON = img/cutter.icns
|
ICON = img/cutter.icns
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QLibraryInfo>
|
||||||
|
|
||||||
#ifdef CUTTER_ENABLE_JUPYTER
|
#ifdef CUTTER_ENABLE_JUPYTER
|
||||||
#include "common/JupyterConnection.h"
|
#include "common/JupyterConnection.h"
|
||||||
@ -22,6 +24,43 @@
|
|||||||
|
|
||||||
CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc, argv)
|
CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
QTranslator *t = new QTranslator;
|
||||||
|
QTranslator *qtBaseTranslator = new QTranslator;
|
||||||
|
QTranslator *qtTranslator = new QTranslator;
|
||||||
|
QString language = Config()->getCurrLocale().bcp47Name();
|
||||||
|
auto allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
|
||||||
|
QLocale::AnyCountry);
|
||||||
|
|
||||||
|
QString langPrefix;
|
||||||
|
if (language != "en") {
|
||||||
|
for (auto &it : allLocales) {
|
||||||
|
langPrefix = it.bcp47Name();
|
||||||
|
if (langPrefix == language) {
|
||||||
|
t->load(QString(QCoreApplication::applicationDirPath() + QDir::separator() +
|
||||||
|
"translations" + QDir::separator() +
|
||||||
|
"cutter_%1.qm").arg(langPrefix));
|
||||||
|
installTranslator(t);
|
||||||
|
QApplication::setLayoutDirection(it.textDirection());
|
||||||
|
QLocale::setDefault(it);
|
||||||
|
|
||||||
|
QString translationsPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
|
if (qtTranslator->load(it, "qt", "_", translationsPath)) {
|
||||||
|
installTranslator(qtTranslator);
|
||||||
|
} else {
|
||||||
|
delete qtTranslator;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (qtBaseTranslator->load(it, "qtbase", "_", translationsPath)) {
|
||||||
|
installTranslator(qtBaseTranslator);
|
||||||
|
} else {
|
||||||
|
delete qtBaseTranslator;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setOrganizationName("Cutter");
|
setOrganizationName("Cutter");
|
||||||
setApplicationName("Cutter");
|
setApplicationName("Cutter");
|
||||||
setApplicationVersion(CUTTER_VERSION_FULL);
|
setApplicationVersion(CUTTER_VERSION_FULL);
|
||||||
|
@ -109,6 +109,16 @@ void Configuration::resetAll()
|
|||||||
emit fontsUpdated();
|
emit fontsUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLocale Configuration::getCurrLocale() const
|
||||||
|
{
|
||||||
|
return s.value("locale", QLocale().system()).toLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Configuration::setLocale(const QLocale &l)
|
||||||
|
{
|
||||||
|
s.setValue("locale", l);
|
||||||
|
}
|
||||||
|
|
||||||
void Configuration::loadDefaultTheme()
|
void Configuration::loadDefaultTheme()
|
||||||
{
|
{
|
||||||
/* Load Qt Theme */
|
/* Load Qt Theme */
|
||||||
|
@ -36,6 +36,10 @@ public:
|
|||||||
|
|
||||||
void resetAll();
|
void resetAll();
|
||||||
|
|
||||||
|
// Languages
|
||||||
|
QLocale getCurrLocale() const;
|
||||||
|
void setLocale(const QLocale &l);
|
||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
const QFont getFont() const;
|
const QFont getFont() const;
|
||||||
void setFont(const QFont &font);
|
void setFont(const QFont &font);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
|
#include <QTranslator>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
@ -14,6 +15,34 @@
|
|||||||
#include "common/ColorSchemeFileSaver.h"
|
#include "common/ColorSchemeFileSaver.h"
|
||||||
#include "widgets/ColorSchemePrefWidget.h"
|
#include "widgets/ColorSchemePrefWidget.h"
|
||||||
|
|
||||||
|
QStringList findLanguages()
|
||||||
|
{
|
||||||
|
QDir dir(QCoreApplication::applicationDirPath() + QDir::separator() +
|
||||||
|
"translations");
|
||||||
|
QStringList fileNames = dir.entryList(QStringList("cutter_*.qm"), QDir::Files,
|
||||||
|
QDir::Name);
|
||||||
|
|
||||||
|
QStringList languages;
|
||||||
|
QString currLanguageName;
|
||||||
|
auto allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
|
||||||
|
QLocale::AnyCountry);
|
||||||
|
|
||||||
|
for (auto i : fileNames) {
|
||||||
|
QString localeName = i.mid(sizeof("cutter_") - 1, 2);
|
||||||
|
for (auto j : allLocales) {
|
||||||
|
if (j.name().startsWith(localeName)) {
|
||||||
|
currLanguageName = j.nativeLanguageName();
|
||||||
|
currLanguageName = currLanguageName.at(0).toUpper() +
|
||||||
|
currLanguageName.right(currLanguageName.length() - 1);
|
||||||
|
languages << currLanguageName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return languages << "English";
|
||||||
|
}
|
||||||
|
|
||||||
AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog, QWidget *parent)
|
AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui(new Ui::AppearanceOptionsWidget)
|
ui(new Ui::AppearanceOptionsWidget)
|
||||||
@ -24,7 +53,22 @@ AppearanceOptionsWidget::AppearanceOptionsWidget(PreferencesDialog *dialog, QWid
|
|||||||
updateFontFromConfig();
|
updateFontFromConfig();
|
||||||
updateThemeFromConfig();
|
updateThemeFromConfig();
|
||||||
|
|
||||||
connect(Config(), &Configuration::fontsUpdated, this, &AppearanceOptionsWidget::updateFontFromConfig);
|
QStringList langs = findLanguages();
|
||||||
|
ui->languageComboBox->addItems(langs);
|
||||||
|
|
||||||
|
QString curr = Config()->getCurrLocale().nativeLanguageName();
|
||||||
|
curr = curr.at(0).toUpper() + curr.right(curr.length() - 1);
|
||||||
|
if (!langs.contains(curr)) {
|
||||||
|
curr = "English";
|
||||||
|
}
|
||||||
|
ui->languageComboBox->setCurrentText(curr);
|
||||||
|
connect(ui->languageComboBox,
|
||||||
|
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
|
this,
|
||||||
|
&AppearanceOptionsWidget::onLanguageComboBoxCurrentIndexChanged);
|
||||||
|
|
||||||
|
connect(Config(), &Configuration::fontsUpdated, this,
|
||||||
|
&AppearanceOptionsWidget::updateFontFromConfig);
|
||||||
connect(ui.get()->colorComboBox, &QComboBox::currentTextChanged, [&](const QString & name) {
|
connect(ui.get()->colorComboBox, &QComboBox::currentTextChanged, [&](const QString & name) {
|
||||||
static_cast<ColorSchemePrefWidget *>(ui.get()->colorSchemePrefWidget)->setNewScheme(name);
|
static_cast<ColorSchemePrefWidget *>(ui.get()->colorSchemePrefWidget)->setNewScheme(name);
|
||||||
});
|
});
|
||||||
@ -114,3 +158,24 @@ void AppearanceOptionsWidget::on_deleteButton_clicked()
|
|||||||
{
|
{
|
||||||
ColorSchemeFileWorker().deleteScheme(Config()->getCurrentTheme());
|
ColorSchemeFileWorker().deleteScheme(Config()->getCurrentTheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AppearanceOptionsWidget::onLanguageComboBoxCurrentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
QString language = ui->languageComboBox->itemText(index).toLower();
|
||||||
|
auto allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript,
|
||||||
|
QLocale::AnyCountry);
|
||||||
|
|
||||||
|
for (auto &it : allLocales) {
|
||||||
|
if (it.nativeLanguageName().toLower() == language) {
|
||||||
|
Config()->setLocale(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QMessageBox mb;
|
||||||
|
mb.setWindowTitle(tr("Language settings"));
|
||||||
|
mb.setText(tr("Language will be changed after next application start."));
|
||||||
|
mb.setIcon(QMessageBox::Information);
|
||||||
|
mb.setStandardButtons(QMessageBox::Ok);
|
||||||
|
mb.exec();
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ private slots:
|
|||||||
void on_colorComboBox_currentIndexChanged(int index);
|
void on_colorComboBox_currentIndexChanged(int index);
|
||||||
void on_copyButton_clicked();
|
void on_copyButton_clicked();
|
||||||
void on_deleteButton_clicked();
|
void on_deleteButton_clicked();
|
||||||
|
void onLanguageComboBoxCurrentIndexChanged(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,14 +56,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="themeLabel">
|
<widget class="QLabel" name="themeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Qt Theme:</string>
|
<string>Qt Theme:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="themeComboBox">
|
<widget class="QComboBox" name="themeComboBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
@ -83,14 +83,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="colorLabel">
|
<widget class="QLabel" name="colorLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color Theme</string>
|
<string>Color Theme</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="colorComboBox">
|
<widget class="QComboBox" name="colorComboBox">
|
||||||
@ -137,6 +137,23 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="languageLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Language</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="languageComboBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user