Add CMake option to install translations

Fixes #485
This commit is contained in:
Jonas Kvinge
2020-08-13 19:53:36 +02:00
parent dd0ab897aa
commit a27ae7e4a6
6 changed files with 32 additions and 14 deletions

View File

@@ -1243,6 +1243,10 @@ if(NOT APPLE)
install(TARGETS strawberry RUNTIME DESTINATION bin)
endif()
if(INSTALL_TRANSLATIONS_FILES)
install(FILES ${INSTALL_TRANSLATIONS_FILES} DESTINATION share/translations)
endif()
if(APPLE)
set_target_properties(strawberry PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/../dist/macos/Info.plist")
endif (APPLE)

View File

@@ -58,9 +58,10 @@
#cmakedefine HAVE_TAGLIB_DSDIFFFILE
#cmakedefine USE_BUNDLE
#define USE_BUNDLE_DIR "${USE_BUNDLE_DIR}"
#cmakedefine HAVE_TRANSLATIONS
#cmakedefine INSTALL_TRANSLATIONS
#define TRANSLATIONS_DIR "${CMAKE_INSTALL_PREFIX}/share/translations"
#endif // CONFIG_H_IN

View File

@@ -225,7 +225,7 @@ int main(int argc, char* argv[]) {
// Resources
Q_INIT_RESOURCE(data);
Q_INIT_RESOURCE(icons);
#ifdef HAVE_TRANSLATIONS
#if defined(HAVE_TRANSLATIONS) && !defined(INSTALL_TRANSLATIONS)
Q_INIT_RESOURCE(translations);
#endif
@@ -254,6 +254,7 @@ int main(int argc, char* argv[]) {
translations->LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
translations->LoadTranslation("strawberry", ":/translations", language);
translations->LoadTranslation("strawberry", TRANSLATIONS_DIR, language);
translations->LoadTranslation("strawberry", a.applicationDirPath(), language);
translations->LoadTranslation("strawberry", QDir::currentPath(), language);

View File

@@ -37,6 +37,7 @@
#include <QSpinBox>
#include <QComboBox>
#include <QGroupBox>
#include <QStandardPaths>
#include "core/iconloader.h"
#include "core/mainwindow.h"
@@ -73,8 +74,12 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog) : SettingsP
#ifdef HAVE_TRANSLATIONS
// Populate the language combo box. We do this by looking at all the compiled in translations.
QDir dir(":/translations/");
QStringList codes(dir.entryList(QStringList() << "*.qm"));
QDir dir1(":/translations/");
QDir dir2(TRANSLATIONS_DIR);
QStringList codes(dir1.entryList(QStringList() << "*.qm"));
if (dir2.exists()) {
codes << dir2.entryList(QStringList() << "*.qm");
}
QRegularExpression lang_re("^strawberry_(.*).qm$");
for (const QString &filename : codes) {