summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-04 18:40:24 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-04 19:48:09 +0100
commitf08dc187499d2895f50f7e2e7e99bf698b0c0738 (patch)
tree7b15638804b92fb99ffa07dc45fb29aef4d7cd80
parenta308e5cd2c6769750f8f6b4e486a8e66b591dafe (diff)
cmake, main: add translation support
-rwxr-xr-xCMakeLists.txt8
-rw-r--r--cmake/opentrack-boilerplate.cmake20
-rw-r--r--cmake/opentrack-clean-build-directory.cmake2
-rw-r--r--cmake/opentrack-hier.cmake3
-rw-r--r--cmake/opentrack-install.cmake28
-rw-r--r--cmake/opentrack-qt.cmake1
-rw-r--r--gui/main-window.ui4
-rw-r--r--gui/main.cpp9
-rw-r--r--gui/options-dialog.ui47
9 files changed, 108 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7329c92..a953c1e7 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,9 +28,13 @@ include(opentrack-build)
project(opentrack)
cmake_minimum_required(VERSION 2.8.11)
+set_property(GLOBAL PROPERTY opentrack-all-modules "")
+set_property(GLOBAL PROPERTY opentrack-all-source-dirs "")
+set(opentrack-all-translations pl_PL ru_RU)
+
+include(opentrack-policy)
include(opentrack-word-size)
include(opentrack-hier)
-include(opentrack-policy)
include(opentrack-qt)
include(opentrack-platform)
include(opentrack-boilerplate)
@@ -70,3 +74,5 @@ foreach(i ${opentrack-subprojects})
get_filename_component(i ${i} DIRECTORY)
add_subdirectory(${i})
endforeach()
+
+merge_translations()
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index 8efc6129..fc26f685 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -214,4 +214,24 @@ function(opentrack_boilerplate n)
opentrack_install_pdb_current_project()
endif()
endif()
+
+ set(langs "")
+ foreach(i ${opentrack-all-translations})
+ set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts")
+ list(APPEND langs "${t}")
+ get_property(tt GLOBAL PROPERTY opentrack-${i}-ts)
+ set(tt ${tt} ${t})
+ set_property(GLOBAL PROPERTY opentrack-${i}-ts ${tt})
+ endforeach()
+
+ get_property(modules GLOBAL PROPERTY opentrack-all-modules)
+ list(APPEND modules "${n}")
+ set_property(GLOBAL PROPERTY opentrack-all-modules "${modules}")
+
+ add_custom_target(${n}-i18n
+ COMMAND cmake -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang"
+ COMMAND "${Qt5_DIR}/../../../bin/lupdate" -silent -recursive -no-obsolete -locations relative . -ts ${langs}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ SOURCES ${langs})
endfunction()
+
diff --git a/cmake/opentrack-clean-build-directory.cmake b/cmake/opentrack-clean-build-directory.cmake
index bf79281e..ab9fffaf 100644
--- a/cmake/opentrack-clean-build-directory.cmake
+++ b/cmake/opentrack-clean-build-directory.cmake
@@ -37,7 +37,7 @@ function(cleanup_build_dir)
# let's hope nothing bad happens
file(REMOVE_RECURSE ${files_})
- execute_process(COMMAND cmake . WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" OUTPUT_QUIET)
+ #execute_process(COMMAND cmake . WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" OUTPUT_QUIET)
endfunction()
cleanup_build_dir()
diff --git a/cmake/opentrack-hier.cmake b/cmake/opentrack-hier.cmake
index 195b6333..8ba62830 100644
--- a/cmake/opentrack-hier.cmake
+++ b/cmake/opentrack-hier.cmake
@@ -17,6 +17,7 @@ if(NOT opentrack-hier-included)
set(opentrack-hier-str RUNTIME DESTINATION . LIBRARY DESTINATION .)
set(opentrack-doc-pfx "./doc")
set(opentrack-doc-src-pfx "./source-code")
+ set(opentrack-i18n-pfx "${opentrack-hier-pfx}")
elseif(WIN32)
set(opentrack-hier-pfx "./modules")
set(opentrack-hier-path "/modules/")
@@ -24,6 +25,7 @@ if(NOT opentrack-hier-included)
set(opentrack-doc-pfx "./doc")
set(opentrack-doc-src-pfx "./source-code")
set(opentrack-hier-str RUNTIME DESTINATION ./modules/ LIBRARY DESTINATION ./modules/)
+ set(opentrack-i18n-pfx "./i18n")
else()
set(opentrack-hier-pfx "libexec/opentrack")
set(opentrack-hier-path "/../libexec/opentrack/")
@@ -32,6 +34,7 @@ if(NOT opentrack-hier-included)
set(opentrack-doc-src-pfx "./share/doc/opentrack/source-code")
set(opentrack-install-rpath "${CMAKE_INSTALL_PREFIX}/${opentrack-hier-pfx}")
set(opentrack-hier-str ARCHIVE DESTINATION lib/opentrack LIBRARY DESTINATION ${opentrack-hier-pfx} RUNTIME DESTINATION bin)
+ set(opentrack-i18n-pfx "libexec/opentrack/i18n")
endif()
function(opentrack_escape_string var str)
diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake
index 601c89c3..3e77e396 100644
--- a/cmake/opentrack-install.cmake
+++ b/cmake/opentrack-install.cmake
@@ -45,3 +45,31 @@ function(opentrack_install_sources n)
endforeach()
opentrack_inst2("${opentrack-doc-src-pfx}/${subdir}" FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
endfunction()
+
+function(merge_translations)
+ set(all-deps "")
+
+ install(CODE "file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/i18n\")")
+
+ get_property(modules GLOBAL PROPERTY opentrack-all-modules)
+
+ foreach(i ${opentrack-all-translations})
+ get_property(ts GLOBAL PROPERTY opentrack-${i}-ts)
+
+ set(qm-output "${CMAKE_BINARY_DIR}/${i}.qm")
+
+ set(deps "")
+ foreach(k ${modules})
+ list(APPEND deps "${k}-i18n")
+ endforeach()
+
+ add_custom_target(i18n-lang-${i}
+ COMMAND "${Qt5_DIR}/../../../bin/lrelease" -nounfinished -silent ${ts} -qm "${qm-output}"
+ DEPENDS ${deps}
+ )
+ list(APPEND all-deps "i18n-lang-${i}")
+ install(FILES "${qm-output}" DESTINATION "${opentrack-i18n-pfx}" RENAME "${i}.qm" ${opentrack-perms})
+ endforeach()
+ add_custom_target(i18n ALL DEPENDS ${all-deps})
+endfunction()
+
diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake
index ded4ec41..bb492eda 100644
--- a/cmake/opentrack-qt.cmake
+++ b/cmake/opentrack-qt.cmake
@@ -22,3 +22,4 @@ if(MSVC AND NOT is-msvc EQUAL 0)
endforeach()
")
endif()
+
diff --git a/gui/main-window.ui b/gui/main-window.ui
index 3340aca0..e726d4d6 100644
--- a/gui/main-window.ui
+++ b/gui/main-window.ui
@@ -275,7 +275,7 @@
</sizepolicy>
</property>
<property name="title">
- <string notr="true">Raw tracker data</string>
+ <string>Raw tracker data</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<property name="leftMargin">
@@ -599,7 +599,7 @@
</sizepolicy>
</property>
<property name="title">
- <string notr="true">Game data</string>
+ <string>Game data</string>
</property>
<layout class="QGridLayout" name="gridLayout_14">
<property name="leftMargin">
diff --git a/gui/main.cpp b/gui/main.cpp
index 763f1cb5..de904f94 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -5,6 +5,8 @@
# include <QCoreApplication>
# include <QFile>
# include <QString>
+# include <QLocale>
+# include <QTranslator>
#endif
#include "migration/migration.hpp"
@@ -128,6 +130,8 @@ main(int argc, char** argv)
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
+
+ QTranslator t;
QApplication app(argc, argv);
set_qt_style();
@@ -137,6 +141,11 @@ main(int argc, char** argv)
add_win32_path();
#endif
+ // QLocale::setDefault(QLocale("pl_PL")); // force i18n for testing
+
+ (void) t.load(QLocale(), "", "", QCoreApplication::applicationDirPath() + "/i18n", ".qm");
+ (void) QCoreApplication::installTranslator(&t);
+
do
{
mem<MainWindow> w = std::make_shared<MainWindow>();
diff --git a/gui/options-dialog.ui b/gui/options-dialog.ui
index fba5e1a2..6606e28c 100644
--- a/gui/options-dialog.ui
+++ b/gui/options-dialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>459</width>
- <height>616</height>
+ <height>615</height>
</rect>
</property>
<property name="windowTitle">
@@ -40,6 +40,9 @@
<string>Shortcuts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="bottomMargin">
+ <number>2</number>
+ </property>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
@@ -68,6 +71,12 @@
<string notr="true">QGroupBox { border: 0; }</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
+ <property name="leftMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
<property name="horizontalSpacing">
<number>20</number>
</property>
@@ -201,6 +210,12 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="center_text">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>3</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string/>
</property>
@@ -218,6 +233,12 @@
</item>
<item row="0" column="0">
<widget class="QLabel" name="textLabel2_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>7</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Center</string>
</property>
@@ -333,7 +354,7 @@
<item>
<widget class="QCheckBox" name="trayp">
<property name="text">
- <string>Enable</string>
+ <string>Enable tray</string>
</property>
</widget>
</item>
@@ -538,10 +559,10 @@
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="pos_rz">
<property name="suffix">
- <string> deg.</string>
+ <string>°</string>
</property>
<property name="decimals">
- <number>3</number>
+ <number>2</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
@@ -607,10 +628,10 @@
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="pos_ry">
<property name="suffix">
- <string> deg.</string>
+ <string>°</string>
</property>
<property name="decimals">
- <number>3</number>
+ <number>2</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
@@ -660,10 +681,10 @@
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="pos_rx">
<property name="suffix">
- <string> deg.</string>
+ <string>°</string>
</property>
<property name="decimals">
- <number>3</number>
+ <number>2</number>
</property>
<property name="minimum">
<double>-180.000000000000000</double>
@@ -1384,12 +1405,18 @@
<property name="title">
<string>CSV Data Logging</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_211">
+ <layout class="QVBoxLayout" name="verticalLayout_11">
<property name="bottomMargin">
- <number>0</number>
+ <number>11</number>
</property>
<item>
<widget class="QCheckBox" name="tracklogging_enabled">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
<property name="text">
<string>Enable - You will be asked for a filename whenever tracking starts</string>
</property>