mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add translation to the helper
This commit is contained in:
parent
b863eedd96
commit
d112446d87
@ -157,9 +157,6 @@ int main(int argc, char *argv[])
|
||||
daemon(0, 0);
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// check if exists
|
||||
if (restoreExistSession())
|
||||
return 0;
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
@ -186,6 +183,10 @@ int main(int argc, char *argv[])
|
||||
cout << versionMessage().toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check if exists
|
||||
if (restoreExistSession())
|
||||
return 0;
|
||||
MainWindow w(0, args, &translator);
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -3,7 +3,12 @@ set (SUBPROJECT netctlgui-helper)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations-helper)
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
|
||||
|
||||
# additional targets
|
||||
set (TARGETS "")
|
||||
|
@ -2,6 +2,9 @@
|
||||
file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources-helper.qrc)
|
||||
|
||||
# include_path
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
@ -13,19 +16,43 @@ link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||
if (USE_QT5)
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5DBus REQUIRED)
|
||||
find_package(Qt5LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS})
|
||||
add_definitions(${Qt5DBus_DEFINITIONS})
|
||||
add_definitions(${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${LANGUAGE})
|
||||
string (REPLACE ".ts" ".qm" QM ${TS})
|
||||
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
|
||||
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
|
||||
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||
endforeach ()
|
||||
add_custom_target (translations-helper COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations-helper COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
else ()
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${LANGUAGE})
|
||||
string (REPLACE ".ts" ".qm" QM ${TS})
|
||||
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
|
||||
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
|
||||
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||
endforeach ()
|
||||
add_custom_target (translations-header COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations-header COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
endif()
|
||||
|
||||
add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES})
|
||||
add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin
|
||||
|
1
sources/helper/src/language.cpp
Symbolic link
1
sources/helper/src/language.cpp
Symbolic link
@ -0,0 +1 @@
|
||||
../../gui/src/language.cpp
|
1
sources/helper/src/language.h
Symbolic link
1
sources/helper/src/language.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../gui/src/language.h
|
@ -21,9 +21,11 @@
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "language.h"
|
||||
#include "messages.h"
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
@ -80,9 +82,27 @@ int main(int argc, char *argv[])
|
||||
args[QString("error")] = true;
|
||||
}
|
||||
}
|
||||
if (args[QString("debug")].toBool())
|
||||
if ((args[QString("debug")].toBool()) ||
|
||||
(args[QString("help")].toBool()) ||
|
||||
(args[QString("info")].toBool()) ||
|
||||
(args[QString("version")].toBool()) ||
|
||||
(args[QString("error")].toBool()))
|
||||
args[QString("nodaemon")] = true;
|
||||
|
||||
// detach from console
|
||||
if (!args[QString("nodaemon")].toBool())
|
||||
daemon(0, 0);
|
||||
#if QT_VERSION >= 0x050000
|
||||
QCoreApplication::setSetuidAllowed(true);
|
||||
#endif
|
||||
QCoreApplication a(argc, argv);
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations-helper/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// running
|
||||
if (args[QString("error")].toBool()) {
|
||||
cout << errorMessage().toUtf8().data() << endl;
|
||||
@ -103,17 +123,9 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
// detach from console
|
||||
if (!args[QString("nodaemon")].toBool())
|
||||
daemon(0, 0);
|
||||
#if QT_VERSION >= 0x050000
|
||||
QCoreApplication::setSetuidAllowed(true);
|
||||
#endif
|
||||
QCoreApplication a(argc, argv);
|
||||
// check if exists
|
||||
if (checkExistSession())
|
||||
return 0;
|
||||
|
||||
NetctlHelper w(0, args);
|
||||
return a.exec();
|
||||
}
|
||||
|
7
sources/resources/resources-helper.qrc
Normal file
7
sources/resources/resources-helper.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<!-- helper translations -->
|
||||
<file>translations-helper/en.qm</file>
|
||||
<file>translations-helper/ru.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
94
sources/resources/translations-helper/en.ts
Normal file
94
sources/resources/translations-helper/en.ts
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en">
|
||||
<context>
|
||||
<name>NetctlHelper</name>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="28"/>
|
||||
<source>Unknown flag
|
||||
</source>
|
||||
<translation>Unknown flag
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="52"/>
|
||||
<source>Usage:</source>
|
||||
<translation>Usage:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="54"/>
|
||||
<source>Options:</source>
|
||||
<translation>Options:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="57"/>
|
||||
<source>read configuration from this file</source>
|
||||
<translation>read configuration from this file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="59"/>
|
||||
<source>print debug information</source>
|
||||
<translation>print debug information</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="61"/>
|
||||
<source>do not start as daemon</source>
|
||||
<translation>do not start as daemon</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="62"/>
|
||||
<source>Show messages:</source>
|
||||
<translation>Show messages:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="64"/>
|
||||
<source>show version and exit</source>
|
||||
<translation>show version and exit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="66"/>
|
||||
<source>show build information and exit</source>
|
||||
<translation>show build information and exit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="68"/>
|
||||
<source>show this help and exit</source>
|
||||
<translation>show this help and exit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="78"/>
|
||||
<source>Build date: %1</source>
|
||||
<translation>Build date: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="80"/>
|
||||
<source>cmake flags</source>
|
||||
<translation>cmake flags</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="90"/>
|
||||
<source>DBus configuration</source>
|
||||
<translation>DBus configuration</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="99"/>
|
||||
<source>Documentation</source>
|
||||
<translation>Documentation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="114"/>
|
||||
<source>Version</source>
|
||||
<translation>Version</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="117"/>
|
||||
<source>Author</source>
|
||||
<translation>Author</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="120"/>
|
||||
<source>License</source>
|
||||
<translation>License</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
93
sources/resources/translations-helper/netctlgui-helper.ts
Normal file
93
sources/resources/translations-helper/netctlgui-helper.ts
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>NetctlHelper</name>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="28"/>
|
||||
<source>Unknown flag
|
||||
</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="52"/>
|
||||
<source>Usage:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="54"/>
|
||||
<source>Options:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="57"/>
|
||||
<source>read configuration from this file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="59"/>
|
||||
<source>print debug information</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="61"/>
|
||||
<source>do not start as daemon</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="62"/>
|
||||
<source>Show messages:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="64"/>
|
||||
<source>show version and exit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="66"/>
|
||||
<source>show build information and exit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="68"/>
|
||||
<source>show this help and exit</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="78"/>
|
||||
<source>Build date: %1</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="80"/>
|
||||
<source>cmake flags</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="90"/>
|
||||
<source>DBus configuration</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="99"/>
|
||||
<source>Documentation</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="114"/>
|
||||
<source>Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="117"/>
|
||||
<source>Author</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="120"/>
|
||||
<source>License</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
94
sources/resources/translations-helper/ru.ts
Normal file
94
sources/resources/translations-helper/ru.ts
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="ru_RU">
|
||||
<context>
|
||||
<name>NetctlHelper</name>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="28"/>
|
||||
<source>Unknown flag
|
||||
</source>
|
||||
<translation>Неизвестный флаг
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="52"/>
|
||||
<source>Usage:</source>
|
||||
<translation>Использование:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="54"/>
|
||||
<source>Options:</source>
|
||||
<translation>Опции:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="57"/>
|
||||
<source>read configuration from this file</source>
|
||||
<translation>прочитать настройки из данного файла</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="59"/>
|
||||
<source>print debug information</source>
|
||||
<translation>показать отладочную информацию</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="61"/>
|
||||
<source>do not start as daemon</source>
|
||||
<translation>не запускать как демон</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="62"/>
|
||||
<source>Show messages:</source>
|
||||
<translation>Показать сообщения:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="64"/>
|
||||
<source>show version and exit</source>
|
||||
<translation>показать версию и выход</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="66"/>
|
||||
<source>show build information and exit</source>
|
||||
<translation>показать информацию о сборке и выход</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="68"/>
|
||||
<source>show this help and exit</source>
|
||||
<translation>показать справку и выход</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="78"/>
|
||||
<source>Build date: %1</source>
|
||||
<translation>Дата сборки: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="80"/>
|
||||
<source>cmake flags</source>
|
||||
<translation>Флаги cmake</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="90"/>
|
||||
<source>DBus configuration</source>
|
||||
<translation>Настройка DBus</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="99"/>
|
||||
<source>Documentation</source>
|
||||
<translation>Документация</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="114"/>
|
||||
<source>Version</source>
|
||||
<translation>Версия</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="117"/>
|
||||
<source>Author</source>
|
||||
<translation>Автор</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../helper/src/messages.cpp" line="120"/>
|
||||
<source>License</source>
|
||||
<translation>Лицензия</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
Loading…
Reference in New Issue
Block a user