From 532e4ec95f93ee491357efdf4aaff3c66ad7b31f Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 18 Oct 2018 00:18:11 +0200 Subject: [PATCH] Qt: made translations possible, added german translation (#5) --- CMakeLists.txt | 26 +++- src/interface_qt.cpp | 15 +- src/whyblocked.ui | 5 +- translations/whyblocked_de.ts | 251 ++++++++++++++++++++++++++++++++++ 4 files changed, 286 insertions(+), 11 deletions(-) create mode 100644 translations/whyblocked_de.ts diff --git a/CMakeLists.txt b/CMakeLists.txt index 02bc3f6..a0fb125 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.6) project (whyblocked - VERSION 0.8.0 + VERSION 0.9.0 LANGUAGES CXX ) @@ -8,6 +8,7 @@ include(GNUInstallDirs) find_package(PkgConfig REQUIRED) pkg_check_modules(LIBXDG_BASEDIR REQUIRED libxdg-basedir) find_package(Qt5Widgets CONFIG REQUIRED) +find_package(Qt5LinguistTools) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -31,18 +32,29 @@ configure_file ( "${PROJECT_BINARY_DIR}/version.hpp" ) +if(Qt5_LRELEASE_EXECUTABLE) + file(GLOB TS_FILES "translations/*.ts") + file(GLOB TS_SRC_FILES "src/*") + qt5_create_translation(QM_FILES ${TS_SRC_FILES} ${TS_FILES} OPTIONS -no-obsolete) + qt5_add_translation(QM_FILES ${TS_FILES}) +endif() + add_executable(whyblocked src/interface_text.cpp src/whyblocked.cpp) target_link_libraries(whyblocked ${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp stdc++fs) install(TARGETS whyblocked DESTINATION ${CMAKE_INSTALL_BINDIR}) if(NOT WITHOUT_QT) - add_executable(whyblocked-gui src/interface_qt.cpp src/whyblocked.cpp) - target_link_libraries(whyblocked-gui - ${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp stdc++fs Qt5::Widgets) - install(TARGETS whyblocked-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) - install(FILES de.tastytea.Whyblocked.desktop DESTINATION - ${CMAKE_INSTALL_DATAROOTDIR}/applications) + add_executable(whyblocked-gui src/interface_qt.cpp src/whyblocked.cpp ${QM_FILES}) + target_link_libraries(whyblocked-gui + ${LIBXDG_BASEDIR_LIBRARIES} vsqlitepp stdc++fs + Qt5::Widgets) + + install(TARGETS whyblocked-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(FILES de.tastytea.Whyblocked.desktop DESTINATION + ${CMAKE_INSTALL_DATAROOTDIR}/applications) + install(FILES ${QM_FILES} DESTINATION + ${CMAKE_INSTALL_DATAROOTDIR}/qt5/translations) endif() diff --git a/src/interface_qt.cpp b/src/interface_qt.cpp index 2e4238a..d7bee7f 100644 --- a/src/interface_qt.cpp +++ b/src/interface_qt.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include "version.hpp" #include "whyblocked.hpp" #include "interface_qt.hpp" @@ -133,8 +135,8 @@ void MainWindow::remove() void MainWindow::about() { - QMessageBox::about(this, tr("About whyblocked"), - tr("

whyblocked %1

" + QMessageBox::about(this, tr("About Whyblocked"), + tr("

Whyblocked %1

" "

Reminds you why you blocked someone.

" "

Sourcecode: " "https://schlomp.space/tastytea/whyblocked

" @@ -258,6 +260,15 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); QCoreApplication::setApplicationName("Whyblocked"); + + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&qtTranslator); + QTranslator appTranslator; + appTranslator.load("whyblocked_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&appTranslator); MainWindow win; win.show(); diff --git a/src/whyblocked.ui b/src/whyblocked.ui index 4d87807..ef15ed9 100644 --- a/src/whyblocked.ui +++ b/src/whyblocked.ui @@ -88,7 +88,7 @@ - toolBar + TopToolBarArea @@ -205,7 +205,8 @@ - + + .. &Edit diff --git a/translations/whyblocked_de.ts b/translations/whyblocked_de.ts new file mode 100644 index 0000000..67d1e0e --- /dev/null +++ b/translations/whyblocked_de.ts @@ -0,0 +1,251 @@ + + + + + DialogAdd + + + Add entry + Eintrag hinzufügen + + + + Memory aids, proof + Gedächtnisstützen, Beweise + + + + Rece&ipts + Be&lege + + + + Add receipt + Beleg hinzufügen + + + + &Add + &Hinzufügen + + + + &Blocked + &Blockiert + + + + &Silenced + &Gedämpft + + + + R&eason + B&egründung + + + + Blocked/Silenced + Blockiert/Gedämpft + + + + &User/Instance + Ben&utzer/Instanz + + + + Remove receipt + Beleg entfernen + + + + Re&move + Ent&fernen + + + + Insert receipt here. + Beleg hier einfügen. + + + + Added %1 to database. + %1 zur Datenbank hinzugefügt. + + + + MainWindow + + + Whyblocked + + + + + Click or press enter to view receipts + Klicken oder Eingabe drücken, um Belege zu anzuzeigen + + + + Memory aids, proof + Gedächtnisstützen, Beweise + + + + &Database + &Datenbank + + + + &Help + &Hilfe + + + + &Add + &Hinzufügen + + + + Add user or instance + Benutzer oder Instanz hinzufügen + + + + Ctrl+N + Strg+N + + + + Re&move + Ent&fernen + + + + Remove user or instance + Benutzer oder Instanz entfernen + + + + Del + Entf + + + + &About + &Über + + + + About this application + Über dieses Programm + + + + &Reload + Neu &laden + + + + Reload database + Datenbank neu laden + + + + Ctrl+R + Strg+R + + + + &Quit + &Beenden + + + + Quit application + Programm beenden + + + + Ctrl+Q + Strg+Q + + + + &Edit + B&earbeiten + + + + + Edit entry + Eintrag bearbeiten + + + + Ctrl+E + Strg+E + + + + User/Instance + Benutzer/Instanz + + + + Blocked/Silenced + Blockiert/Gedämpft + + + + Reason + Begründung + + + + Database loaded. + Datenbank geladen. + + + + blocked + blockiert + + + + silenced + gedämpft + + + + Invalid selection + Ungültige Auswahl + + + + Please select only 1 entry to edit. + Bitte nur 1 Eintrag zum bearbeiten auswählen. + + + + Removed %1 from database. + %1 aus der Datenbank gelöscht. + + + + Select data to remove. + Wähle Daten zum löschen aus. + + + + About Whyblocked + Über Whyblocked + + + + <p><b>Whyblocked</b> %1</p><p>Reminds you why you blocked someone.</p><p>Sourcecode: <a href="https://schlomp.space/tastytea/whyblocked">https://schlomp.space/tastytea/whyblocked</a></p><p><small>Copyright © 2018 <a href="mailto:tastytea@tastytea.de">tastytea</a>.<br>Licence GPLv3: <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a>.<br>This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.</small></p> + <p><b>Whyblocked</b> %1</p><p>Erinnert dich, warum du jemanden blockiertest.</p><p>Quelltext: <a href="https://schlomp.space/tastytea/whyblocked">https://schlomp.space/tastytea/whyblocked</a></p><p><small>Copyright © 2018 <a href="mailto:tastytea@tastytea.de">tastytea</a>.<br>Lizenz GPLv3: <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a>.<br>Für dieses Programm besteht KEINERLEI GARANTIE. Dies ist freie Software, die Sie unter bestimmten Bedingungen weitergeben dürfen.</small></p> + + +