Commit a716f42e authored by Pierre Kim's avatar Pierre Kim

Add initial translation support + Korean translation

parent 9505a0b2
......@@ -18,6 +18,8 @@
namespace WalletGui {
Q_DECL_CONSTEXPR char OPTION_LANGUAGE[] = "Language";
Settings& Settings::instance() {
static Settings inst;
return inst;
......@@ -118,6 +120,19 @@ bool Settings::isEncrypted() const {
return m_settings.contains("encrypted") ? m_settings.value("encrypted").toBool() : false;
}
QString Settings::getLanguage() const {
QString currentLang;
if (m_settings.contains(OPTION_LANGUAGE)) {
currentLang = m_settings.value(OPTION_LANGUAGE).toString();
}
return currentLang;
}
void Settings::setLanguage(const QString& _language) {
m_settings.insert(OPTION_LANGUAGE, _language);
saveSettings();
}
QString Settings::getVersion() const {
return PROJECT_VERSION_LONG;
}
......
......@@ -38,6 +38,7 @@ public:
QString getWalletFile() const;
QString getAddressBookFile() const;
bool isEncrypted() const;
QString getLanguage() const;
QString getVersion() const;
bool isStartOnLoginEnabled() const;
#ifdef Q_OS_WIN
......@@ -47,6 +48,7 @@ public:
void setWalletFile(const QString& _file);
void setEncrypted(bool _encrypted);
void setLanguage(const QString& _language);
void setCurrentTheme(const QString& _theme);
void setStartOnLoginEnabled(bool _enable);
#ifdef Q_OS_WIN
......
// Copyright (c) 2016 The Karbowanec developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ChangeLanguageDialog.h"
#include "ui_changelanguagedialog.h"
#include "Settings.h"
namespace WalletGui {
ChangeLanguageDialog::ChangeLanguageDialog(QWidget* _parent) : QDialog(_parent), m_ui(new Ui::ChangeLanguageDialog) {
m_ui->setupUi(this);
}
ChangeLanguageDialog::~ChangeLanguageDialog() {
}
void ChangeLanguageDialog::initLangList() {
QString currentlang = Settings::instance().getLanguage();
int index = 0;
if(currentlang.compare("kr") == 0)
{
index = 1;
}
/*else if(currentlang.compare("ru") == 0)
{
index = 2;
}*/
m_ui->ChangeLangComboBox->setCurrentIndex(index);
}
QString ChangeLanguageDialog::getLang() const {
QString lang;
int n = m_ui->ChangeLangComboBox->currentIndex();
if (n == 1)
{
lang = "kr";
}
/*else if (n == 2)
{
lang = "ru";
}*/
else
{
lang = "en";
}
return lang;
}
}
// Copyright (c) 2016 The Karbowanec developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <QDialog>
namespace Ui {
class ChangeLanguageDialog;
}
namespace WalletGui {
class ChangeLanguageDialog : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(ChangeLanguageDialog)
public:
ChangeLanguageDialog(QWidget* _parent);
~ChangeLanguageDialog();
QString getLang() const;
void initLangList();
private:
QScopedPointer<Ui::ChangeLanguageDialog> m_ui;
};
}
......@@ -14,6 +14,7 @@
#include "AboutDialog.h"
#include "AnimatedLabel.h"
#include "ChangePasswordDialog.h"
#include "ChangeLanguageDialog.h"
#include "CurrencyAdapter.h"
#include "ExitWidget.h"
#include "MainWindow.h"
......@@ -316,6 +317,16 @@ void MainWindow::setCloseToTray(bool _on) {
#endif
}
void MainWindow::ChangeLanguage() {
ChangeLanguageDialog dlg(&MainWindow::instance());
dlg.initLangList();
if (dlg.exec() == QDialog::Accepted) {
QString language = dlg.getLang();
Settings::instance().setLanguage((language));
QMessageBox::information(this, tr("Language was changed"), tr("The language will be changed after restarting the wallet."), QMessageBox::Ok);
}
}
void MainWindow::about() {
AboutDialog dlg(this);
dlg.exec();
......
......@@ -8,6 +8,7 @@
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QTimer>
#include "ChangeLanguageDialog.h"
class QActionGroup;
......@@ -68,6 +69,7 @@ private:
Q_SLOT void setStartOnLogin(bool _on);
Q_SLOT void setMinimizeToTray(bool _on);
Q_SLOT void setCloseToTray(bool _on);
Q_SLOT void ChangeLanguage();
#ifdef Q_OS_MAC
public:
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChangeLanguageDialog</class>
<widget class="QDialog" name="ChangeLanguageDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>245</width>
<height>92</height>
</rect>
</property>
<property name="windowTitle">
<string>Change language</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select language:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="ChangeLangComboBox">
<item>
<property name="text">
<string>English</string>
</property>
</item>
<item>
<property name="text">
<string>한국어</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="m_cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="m_okButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>m_okButton</sender>
<signal>clicked()</signal>
<receiver>ChangeLanguageDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>500</x>
<y>62</y>
</hint>
<hint type="destinationlabel">
<x>276</x>
<y>44</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_cancelButton</sender>
<signal>clicked()</signal>
<receiver>ChangeLanguageDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>417</x>
<y>62</y>
</hint>
<hint type="destinationlabel">
<x>276</x>
<y>44</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -121,6 +121,7 @@
<addaction name="m_openWalletAction"/>
<addaction name="m_backupWalletAction"/>
<addaction name="m_resetWalletAction"/>
<addaction name="separator"/>
<addaction name="m_exitAction"/>
</widget>
<widget class="QMenu" name="menuSettings">
......@@ -129,6 +130,7 @@
</property>
<addaction name="m_encryptWalletAction"/>
<addaction name="m_changePasswordAction"/>
<addaction name="m_changeLanguageAction"/>
<addaction name="separator"/>
<addaction name="m_startOnLoginAction"/>
<addaction name="m_minimizeToTrayAction"/>
......@@ -289,6 +291,14 @@
<string>Change password</string>
</property>
</action>
<action name="m_changeLanguageAction">
<property name="text">
<string>Change language</string>
</property>
<property name="toolTip">
<string>Change language</string>
</property>
</action>
<action name="m_aboutCryptonoteAction">
<property name="enabled">
<bool>true</bool>
......@@ -526,6 +536,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>m_changeLanguageAction</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>ChangeLanguage()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>449</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>m_aboutQtAction</sender>
<signal>triggered()</signal>
......
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
### translation
find_package(Qt5LinguistTools)
file(GLOB_RECURSE CODE_FILES ${CMAKE_CURRENT_LIST_DIR}/../*.cpp)
file(GLOB_RECURSE UI_FILES ${CMAKE_CURRENT_LIST_DIR}/../*.ui)
file(GLOB TRANSLATION_FILES ${CMAKE_CURRENT_LIST_DIR}/*.ts)
file(GLOB UI_TRANSLATION_FILES ${CMAKE_CURRENT_LIST_DIR}/qt_*.ts)
qt5_create_translation(TRANSLATION_MESSAGES ${CODE_FILES} ${TRANSLATION_FILES})
qt5_create_translation(TRANSLATION_MESSAGES2 ${UI_FILES} ${UI_TRANSLATION_FILES})
qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES})
qt5_add_translation(TRANSLATION_QM2 ${UI_TRANSLATION_FILES})
add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES})
add_custom_target(translations_update DEPENDS ${TRANSLATION_MESSAGES2})
add_custom_target(translations DEPENDS ${TRANSLATION_QM})
add_custom_target(translations_update DEPENDS ${TRANSLATION_QM2})
if(APPLE AND UNIX) ## OSX
install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/Resources/translations)
else()
install(FILES ${TRANSLATION_QM} DESTINATION translations)
endif()
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -9,6 +9,7 @@
#include <QMessageBox>
#include <QSplashScreen>
#include <QStyleFactory>
#include <QTranslator>
#include "CommandLineParser.h"
#include "CurrencyAdapter.h"
......@@ -38,6 +39,33 @@ int main(int argc, char* argv[]) {
Settings::instance().setCommandLineParser(&cmdLineParser);
bool cmdLineParseResult = cmdLineParser.process(app.arguments());
Settings::instance().load();
QTranslator translator;
QTranslator translatorQt;
QString lng = Settings::instance().getLanguage();
if (!lng.isEmpty()) {
translator.load(":/languages/" + lng + ".qm");
translatorQt.load(":/languages/qt_" + lng + ".qm");
if (lng == "kr") {
QLocale::setDefault(QLocale("ko_KR"));
}
/*else if (lng == "ru") {
QLocale::setDefault(QLocale("ru_RU"));
}*/
else {
QLocale::setDefault(QLocale::c());
}
}
else {
translator.load(":/languages/" + QLocale::system().name());
translatorQt.load(":/languages/qt_" + QLocale::system().name());
QLocale::setDefault(QLocale::system().name());
}
app.installTranslator(&translator);
app.installTranslator(&translatorQt);
#ifdef Q_OS_WIN
if(!cmdLineParseResult) {
......
......@@ -33,4 +33,8 @@
<file alias="cryptonote">images/cryptonote.png</file>
<file alias="clock">images/clock.gif</file>
</qresource>
<qresource prefix="/">
<file>languages/kr.qm</file>
<file>languages/qt_kr.qm</file>
</qresource>
</RCC>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment