From bf7453843683494b81dd70232a2093577db34289 Mon Sep 17 00:00:00 2001
From: Jan Darmochwal
Date: Wed, 6 Oct 2010 01:35:05 +0200
Subject: i18n support and German translation
Translation can be done with .ts-files in src/i18n/de.ts. The resulting .qm-files are stored as resources in the program binary.
build.sh has a new option --update-translations that causes the .ts files to be updated
---
CMakeLists.txt | 26 +++++++++++++++++++-
build.sh | 16 ++++++++++++-
src/dialog.cpp | 2 +-
src/i18n/de.ts | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/main.cpp | 9 +++++--
src/ui/dialog.ui | 4 ++--
6 files changed, 122 insertions(+), 7 deletions(-)
create mode 100644 src/i18n/de.ts
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0bc9e02..9601a66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,7 @@ file(GLOB_RECURSE VMCHOOSER_SOURCES src/*.cpp)
file(GLOB_RECURSE VMCHOOSER_MOC_HEADERS src/*.h)
file(GLOB_RECURSE VMCHOOSER_UIS src/ui/*.ui)
file(GLOB_RECURSE VMCHOOSER_RESOURCES src/*.qrc)
+file(GLOB_RECURSE VMCHOOSER_TSS src/i18n/*.ts)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -48,7 +49,6 @@ endif(LIBXML2_FOUND)
#
# Qt4
#
-# TODO: Qt4.3 should do
find_package(Qt4 4.5.0 REQUIRED)
if(QT4_FOUND)
message(STATUS "Qt4 found")
@@ -62,6 +62,29 @@ set(QT_USE_QTSVG TRUE)
include(${QT_USE_FILE})
+option(UPDATE_TRANSLATIONS "Update .ts files (WARNING: make clean will delete the .ts files!)")
+if(VMCHOOSER_TSS)
+ if (UPDATE_TRANSLATIONS)
+ set (FILES_TO_TRANSLATE ${FILES_TO_TRANSLATE} ${VMCHOOSER_SOURCES} ${VMCHOOSER_UIS})
+ QT4_CREATE_TRANSLATION(VMCHOOSER_QMS ${FILES_TO_TRANSLATE} ${VMCHOOSER_TSS} OPTIONS -noobsolete)
+ message(STATUS ".tr files have been updated")
+ else (UPDATE_TRANSLATIONS)
+ QT4_ADD_TRANSLATION(VMCHOOSER_QMS ${VMCHOOSER_TSS})
+ endif (UPDATE_TRANSLATIONS)
+
+ # write a resource file for qm files
+ set(resource_file_content "\n \n")
+ foreach(file ${VMCHOOSER_QMS})
+ get_filename_component(filename ${file} NAME)
+ set(resource_file_content "${resource_file_content} ${filename}\n")
+ endforeach(file)
+ set(resource_file_content "${resource_file_content} \n\n")
+ file(WRITE "${CMAKE_BINARY_DIR}/translation.qrc" "${resource_file_content}")
+ set(VMCHOOSER_RESOURCES ${VMCHOOSER_RESOURCES} "${CMAKE_BINARY_DIR}/translation.qrc")
+
+ #add_custom_target(translations_target DEPENDS ${VMCHOOSER_QMS})
+endif(VMCHOOSER_TSS)
+
QT4_ADD_RESOURCES(VMCHOOSER_RC_SOURCES ${VMCHOOSER_RESOURCES})
QT4_WRAP_UI(VMCHOOSER_UI_HEADERS ${VMCHOOSER_UIS})
QT4_WRAP_CPP(VMCHOOSER_MOC_SOURCES ${VMCHOOSER_MOC_HEADERS})
@@ -77,6 +100,7 @@ add_executable(vmchooser
${VMCHOOSER_MOC_SOURCES}
${VMCHOOSER_UI_HEADERS}
${VMCHOOSER_RC_SOURCES}
+ ${VMCHOOSER_QMS}
)
target_link_libraries(vmchooser
diff --git a/build.sh b/build.sh
index 69041c0..7a515e4 100755
--- a/build.sh
+++ b/build.sh
@@ -8,6 +8,20 @@ BUILDDIR="build"
DIR=$(pwd)
+for OPTION in "$@"
+do
+ if [[ "$OPTION" == "--clean" ]]
+ then
+ rm -r "$BUILDDIR"
+ elif [[ "$OPTION" == "--update-translations" ]]
+ then
+ CMAKE_ARGS="$CMAKE_ARGS -DUPDATE_TRANSLATIONS:BOOL=ON"
+ else
+ echo "usage: $SCRIPTNAME [--clean] [--update-translations]" >&2
+ exit 1
+ fi
+done
+
if [[ ! -f "$DIR"/"$SRCDIR"/CMakeLists.txt ]]
then
echo "$SRCDIR/CMakeLists.txt not found" >&2
@@ -26,6 +40,6 @@ fi
mkdir -p "$BUILDDIR"
cd "$BUILDDIR"
-cmake "$DIR"/"$SRCDIR"/ && make clean && make -j $NCORES
+cmake $CMAKE_ARGS "$DIR"/"$SRCDIR"/ && make -j $NCORES
cd "$DIR"
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 6a931ca..7ebfbcc 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -16,7 +16,7 @@ Dialog::Dialog(QWidget *parent) :
if (ifaceDBus_->isValid()) {
// PVS is running
QStringList accessOptions;
- accessOptions << "None" << "View Only" << "Full";
+ accessOptions << tr("None") << tr("View Only") << tr("Full");
ui->comboBoxLecturer->insertItems(0, accessOptions);
ui->comboBoxOthers->insertItems(0, accessOptions);
diff --git a/src/i18n/de.ts b/src/i18n/de.ts
new file mode 100644
index 0000000..b8063d6
--- /dev/null
+++ b/src/i18n/de.ts
@@ -0,0 +1,72 @@
+
+
+
+
+ Dialog
+
+
+
+ vmchooser
+
+
+
+
+ PVS Einstellungen
+
+
+
+
+ VNC-Zugriff für Dozenten:
+
+
+
+
+ VNC-Zugriff für andere:
+
+
+
+
+ Chat-Nachrichten akzeptieren
+
+
+
+
+ Dateiübertragungen akzeptieren
+
+
+
+
+ Abbrechen
+
+
+
+
+ Start
+
+
+
+
+ kein Zugriff
+
+
+
+
+ nur ansehen
+
+
+
+
+ Vollzugriff
+
+
+
+
+ X Sitzungen
+
+
+
+
+ Virtuelle Sitzungen
+
+
+
diff --git a/src/main.cpp b/src/main.cpp
index 6766403..c44d362 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -3,6 +3,7 @@
#include
#include
+#include
#include "save_restore_session.h"
#include "xsession.h"
#include "vsession.h"
@@ -18,6 +19,10 @@ using namespace std;
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
+ QTranslator translator;
+ translator.load(":" + QLocale::system().name());
+ a.installTranslator(&translator);
+
string version = "0.0.13";
AnyOption* opt = new AnyOption();
char* xmlpath = NULL;
@@ -188,8 +193,8 @@ int main(int argc, char *argv[]) {
Dialog w;
w.resize(width, height);
- w.addItems(xsessions, "X Sessions");
- w.addItems(vsessions, "Virtual Sessions");
+ w.addItems(xsessions, a.translate("Dialog", "X Sessions"));
+ w.addItems(vsessions, a.translate("Dialog", "Virtual Sessions"));
w.selectPreviousSession();
w.show();
return a.exec();
diff --git a/src/ui/dialog.ui b/src/ui/dialog.ui
index fe03b5d..6594b63 100644
--- a/src/ui/dialog.ui
+++ b/src/ui/dialog.ui
@@ -11,7 +11,7 @@
- Dialog
+ vmchooser
-
@@ -146,7 +146,7 @@
-
- Abbrechen
+ Abort
--
cgit v1.2.3-55-g7522