Add translations

pull/3/head
reionwong 5 years ago
parent 43f0a0e20d
commit ea019f4fe4

@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(Qt5 COMPONENTS Core Quick DBus Widgets REQUIRED)
find_package(Qt5 COMPONENTS Core Quick DBus Widgets LinguistTools REQUIRED)
find_package(Libmpv)
qt5_add_dbus_interface(screensaver_inhibit_SRCS ./org.freedesktop.ScreenSaver.xml screensaverdbusinterface)
@ -53,3 +53,10 @@ install(FILES
DESTINATION /usr/share/applications/
COMPONENT Runtime
)
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-videoplayer translations)
install(FILES ${QM_FILES} DESTINATION /usr/share/cutefish-videoplayer/translations)

@ -101,6 +101,11 @@ QtObject {
Component.onCompleted: list["playPauseAction"] = playPauseAction
onTriggered: {
if (playList.playlistView.count === 0) {
fileDialog.open()
return
}
mpv.setProperty("pause", !mpv.getProperty("pause"))
}
}

@ -37,6 +37,9 @@
#include <QStyleFactory>
#include <QThread>
#include <QTranslator>
#include <QLocale>
#include <memory>
static QApplication *createApplication(int &argc, char **argv, const QString &applicationName)
@ -66,6 +69,18 @@ Application::Application(int &argc, char **argv, const QString &applicationName)
// requires the LC_NUMERIC category to be set to "C", so change it back.
std::setlocale(LC_NUMERIC, "C");
// Translations
QLocale locale;
QString qmFilePath = QString("%1/%2.qm").arg("/usr/share/cutefish-videoplayer/translations/").arg(locale.name());
if (QFile::exists(qmFilePath)) {
QTranslator *translator = new QTranslator(QApplication::instance());
if (translator->load(qmFilePath)) {
QApplication::installTranslator(translator);
} else {
translator->deleteLater();
}
}
m_engine = new QQmlApplicationEngine(this);
setupCommandLineParser();
registerQmlTypes();

Loading…
Cancel
Save