Add translations

pull/1/head
reionwong 4 years ago
parent 56a80f3822
commit 8e922e41c3

@ -18,7 +18,7 @@ include(CheckIncludeFiles)
include(CheckSymbolExists)
include(FeatureSummary)
find_package(Qt5 COMPONENTS Core DBus Widgets X11Extras Quick REQUIRED)
find_package(Qt5 COMPONENTS Core DBus Widgets X11Extras Quick LinguistTools REQUIRED)
find_package(X11)
# ----------- Check --------------------
@ -64,3 +64,28 @@ add_subdirectory(screenlocker)
add_subdirectory(checkpass)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# Get the installation directory from qmake
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "qmake is not found.")
endif()
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_QML
OUTPUT_VARIABLE INSTALL_QMLDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(INSTALL_QMLDIR)
message(STATUS "qml directory:" "${INSTALL_QMLDIR}")
else()
message(FATAL_ERROR "qml directory cannot be detected.")
endif()
# Install translations
file(GLOB TS_FILES translations/*.ts)
qt5_create_translation(QM_FILES ${TS_FILES})
add_custom_target(translations DEPENDS ${QM_FILES} SOURCES ${TS_FILES})
add_dependencies(cutefish-screenlocker translations)
install(FILES ${QM_FILES} DESTINATION /usr/share/cutefish-screenlocker/translations)

@ -1,8 +1,23 @@
#include "application.h"
#include <QTranslator>
#include <QLocale>
int main(int argc, char *argv[])
{
Application app(argc, argv);
// Translations
QLocale locale;
QString qmFilePath = QString("%1/%2.qm").arg("/usr/share/cutefish-screenlocker/translations/").arg(locale.name());
if (QFile::exists(qmFilePath)) {
QTranslator *translator = new QTranslator(app.instance());
if (translator->load(qmFilePath)) {
app.installTranslator(translator);
} else {
translator->deleteLater();
}
}
app.setQuitOnLastWindowClosed(false);
app.initialViewSetup();
return app.exec();

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>LockScreen</name>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="202"/>
<source>Password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="225"/>
<source>Unlock</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="274"/>
<source>Please enter your password</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="284"/>
<source>Unlocking failed</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>LockScreen</name>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="202"/>
<source>Password</source>
<translation></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="225"/>
<source>Unlock</source>
<translation></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="274"/>
<source>Please enter your password</source>
<translation></translation>
</message>
<message>
<location filename="../screenlocker/qml/LockScreen.qml" line="284"/>
<source>Unlocking failed</source>
<translation></translation>
</message>
</context>
</TS>
Loading…
Cancel
Save