Commit 1e9ead7b authored by Linus Jahn's avatar Linus Jahn Committed by GitHub

Add i18n support; Add German l10n (#50)

parent 654477b3
......@@ -107,9 +107,12 @@ Makefile*
*.qmlproject.user
*.qmlproject.user.*
# QtCtreator CMake
# QtCreator CMake
CMakeLists.txt.user*
# QtLinguist
*.qm
################## CMake ######################
CMakeCache.txt
......
cmake_minimum_required(VERSION 2.8.11)
set(QT_MIN_VERSION "5.5.0")
set(CMAKE_CXX_STANDARD 14)
set(QT_MIN_VERSION "5.7.0")
project(kaidan)
......@@ -34,17 +35,29 @@ set(CMAKE_AUTORCC ON)
set(EXECUTABLE_OUTPUT_PATH "bin")
#
# Dependecies
#
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Find packages
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick LinguistTools)
find_package(KF5Kirigami REQUIRED)
find_package(Swiften REQUIRED)
find_package(Boost REQUIRED)
#
# Translation
#
include("${CMAKE_SOURCE_DIR}/i18n/CMakeLists.txt")
#
# Sources / Resources
#
# Sources
add_executable(${PROJECT_NAME}
kaidan.qrc
src/main.cpp
......@@ -53,7 +66,10 @@ add_executable(${PROJECT_NAME}
src/RosterItem.cpp
)
# Link libraries
#
# Linker Flags
#
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Qml
......@@ -62,7 +78,10 @@ target_link_libraries(${PROJECT_NAME}
${Boost_LIBRARY}
)
# Pass variables to C++
#
# Global C++ variables
#
target_compile_definitions(${PROJECT_NAME} PRIVATE
APPLICATION_ID="${APPLICATION_ID}"
APPLICATION_NAME="${APPLICATION_NAME}"
......@@ -70,4 +89,6 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
APPLICATION_DESCRIPTION="${APPLICATION_DESCRIPTION}"
VERSION_STRING="${VERSION_STRING}"
BOOST_SIGNALS_NO_DEPRECATION_WARNING=True
)
Kaidan - Cross platform XMPP client
===================================
License of source code:
-----------------------
License of source code and translations:
----------------------------------------
Copyright (C) 2016-2017 Kaidan developers and contributors (see source file
comments and the version control log)
This program is free software: you can redistribute it and/or modify
Kaidan is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
Kaidan is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
......@@ -16,7 +16,7 @@ Create a working directory
Install dependencies to build Kaidan (example for Debian)
* `sudo apt-get install git-core cmake build-essential libstdc++-5-dev zlib1g-dev libglib2.0-dev libssl-dev libxml2-dev libcrypto++-dev libpthread-stubs0-dev libidn11-dev libminiupnpc-dev libnatpmp-dev libswiften-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-regex-dev libboost-program-options-dev libboost-filesystem-dev libboost-serialization-dev libboost-date-time-dev libqt5quick5 libqt5quickcontrols2-5 libqt5quickparticles5 libqt5quickwidgets5 libqt5qml5 libqt5network5 libqt5gui5 libqt5core5a qtdeclarative5-dev qt5-default qml-module-qtquick-controls2 qml-module-org-kde-kirigami`
* `sudo apt-get install git-core cmake build-essential libstdc++-5-dev zlib1g-dev libglib2.0-dev libssl-dev libxml2-dev libcrypto++-dev libpthread-stubs0-dev libidn11-dev libminiupnpc-dev libnatpmp-dev libswiften-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-regex-dev libboost-program-options-dev libboost-filesystem-dev libboost-serialization-dev libboost-date-time-dev libqt5quick5 libqt5quickcontrols2-5 libqt5quickparticles5 libqt5quickwidgets5 libqt5qml5 libqt5network5 libqt5gui5 libqt5core5a qtdeclarative5-dev qttools5-dev qt5-default qml-module-qtquick-controls2 qml-module-org-kde-kirigami`
Get Kaidan source code
......@@ -28,4 +28,3 @@ Finally compile it
* `cd kaidan`
* `cmake .`
* `make -j<number of threads>`
# Translations
# Do not clean up (delete) files in this directory, when using make clean
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1)
file(GLOB FILES_TO_TRANSLATE
${CMAKE_SOURCE_DIR}/src/*.cpp
${CMAKE_SOURCE_DIR}/src/qml/*.qml
)
file(GLOB TRANSLATION_FILES ${CMAKE_CURRENT_LIST_DIR}/*.ts)
# Update ts-files
qt5_create_translation(TRANSLATION_MESSAGES ${FILES_TO_TRANSLATE} ${TRANSLATION_FILES} OPTIONS -silent)
# Generate qm-files from ts-files
qt5_add_translation(TRANSLATION_QM ${TRANSLATION_FILES})
add_custom_target(translations ALL DEPENDS ${TRANSLATION_MESSAGES})
if(APPLE AND UNIX) ## OSX
install(FILES ${TRANSLATION_QM} DESTINATION MultiMC.app/Contents/Resources/translations)
else()
install(FILES ${TRANSLATION_QM} DESTINATION translations)
endif()
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="de_DE">
<context>
<name>ChatPage</name>
<message>
<source>Compose message</source>
<translation>Nachricht verfassen</translation>
</message>
<message>
<source>Send</source>
<translation>Senden</translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Your Jabber-ID:</source>
<translation>Deine Jabber-ID:</translation>
</message>
<message>
<source>user@example.org</source>
<translation>user@beispiel.org</translation>
</message>
<message>
<source>Your Password:</source>
<translation>Dein Passwort:</translation>
</message>
<message>
<source>Password</source>
<translation>Passwort</translation>
</message>
<message>
<source>Connect</source>
<translation>Verbinden</translation>
</message>
<message>
<source>&lt;i&gt;Connecting...&lt;/i&gt;</source>
<translation>&lt;i&gt;Verbinden...&lt;/i&gt;</translation>
</message>
<message>
<source>Retry</source>
<translation>Erneut Versuchen</translation>
</message>
</context>
<context>
<name>RosterPage</name>
<message>
<source>Contacts</source>
<translation>Kontakte</translation>
</message>
</context>
<context>
<name>main</name>
<message>
<source>Successfully parsed command line input.</source>
<translation>Kommandozeileneingaben erfolgreich geparst.</translation>
</message>
</context>
</TS>
......@@ -23,7 +23,8 @@
#include <QObject>
enum Subscription
{ None,
{
None,
To,
From,
Both,
......
......@@ -24,9 +24,11 @@
#include <QCommandLineOption>
#include <QDebug>
#include <QGuiApplication>
#include <QLocale>
#include <QQmlApplicationEngine>
#include <QQuickView>
#include <QQmlContext>
#include <QTranslator>
#include <QtQml>
// Swiften
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
......@@ -72,6 +74,10 @@ int main(int argc, char *argv[])
qmlRegisterType<RosterController>(APPLICATION_ID, 1, 0, "RosterController");
qmlRegisterType<RosterItem>(APPLICATION_ID, 1, 0, "RosterItem");
//
// App
//
// create a qt app
QGuiApplication app(argc, argv);
......@@ -83,6 +89,22 @@ int main(int argc, char *argv[])
// attributes
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// Qt-Translator
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&qtTranslator);
// Kaidan-Translator
QTranslator kaidanTranslator;
kaidanTranslator.load(QLocale::system().name()); // loads the systems locale or none
app.installTranslator(&kaidanTranslator);
//
// Command line arguments
//
// create parser and add a description
QCommandLineParser parser;
parser.setApplicationDescription(QString(APPLICATION_DISPLAY_NAME) +
......@@ -102,15 +124,26 @@ int main(int argc, char *argv[])
parser.showHelp();
return 0;
case CommandLineOk:
qDebug() << "Successfully parsed command line input.";
qDebug() << QCoreApplication::translate("main",
"Successfully parsed command line input.");
break;
}
//
// Kaidan back-end
//
QtEventLoop eventLoop;
BoostNetworkFactories networkFactories(&eventLoop);
Kaidan kaidan(&networkFactories);
//
// QML-GUI
//
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("kaidan", &kaidan);
......
......@@ -34,21 +34,21 @@ Kirigami.ScrollablePage {
// JID field
Kirigami.Label {
text: "Your Jabber-ID:"
text: qsTr("Your Jabber-ID:")
}
Controls.TextField {
id: jidField
placeholderText: "user@example.org"
placeholderText: qsTr("user@example.org")
Layout.fillWidth: true
}
// Password field
Kirigami.Label {
text: "Your Password:"
text: qsTr("Your Password:")
}
Controls.TextField {
id: passField
placeholderText: "Password"
placeholderText: qsTr("Password")
echoMode: TextInput.Password
Layout.fillWidth: true
}
......@@ -56,15 +56,15 @@ Kirigami.ScrollablePage {
// Connect button
Controls.Button {
id: connectButton
text: "Connect"
text: qsTr("Connect")
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
onClicked: {
// disable the button
connectButton.enabled = false;
connectButton.text = "<i>Connecting...</i>"
// connect to given account data
connectButton.text = qsTr("<i>Connecting...</i>")
kaidan.mainConnect(jidField.text, passField.text);
}
}
......@@ -79,7 +79,7 @@ Kirigami.ScrollablePage {
}
function enableConnectButton() {
connectButton.text = "Retry"
connectButton.text = qsTr("Retry")
connectButton.enabled = true
}
......
......@@ -23,7 +23,7 @@ import org.kde.kirigami 1.0 as Kirigami
import harbour.kaidan 1.0
Kirigami.ScrollablePage {
title: "Contacts"
title: qsTr("Contacts")
ListView {
model: kaidan.rosterController.rosterList
......
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