Add a CMake option for deploying Qt translations
This commit is contained in:
@@ -39,7 +39,7 @@ before_install:
|
||||
install:
|
||||
- . ${TRAVIS_BUILD_DIR}/.travis/${TRAVIS_OS_NAME}.${TARGET_OS}.install.sh
|
||||
before_script:
|
||||
- export CMAKE_FLAGS="-DWANT_QT5=$QT5 -DUSE_WERROR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
- export CMAKE_FLAGS="-DWANT_QT5=$QT5 -DUSE_WERROR=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUNDLE_QT_TRANSLATIONS=ON"
|
||||
- if [ -z "$TRAVIS_TAG" ]; then export CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_CCACHE=ON"; fi
|
||||
script:
|
||||
- . ${TRAVIS_BUILD_DIR}/.travis/${TRAVIS_OS_NAME}.${TARGET_OS}.script.sh
|
||||
|
||||
@@ -68,6 +68,7 @@ OPTION(WANT_VST "Include VST support" ON)
|
||||
OPTION(WANT_VST_NOWINE "Include partial VST support (without wine)" OFF)
|
||||
OPTION(WANT_WINMM "Include WinMM MIDI support" OFF)
|
||||
OPTION(WANT_QT5 "Build with Qt5" OFF)
|
||||
OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF)
|
||||
|
||||
|
||||
IF(LMMS_BUILD_APPLE)
|
||||
@@ -92,6 +93,7 @@ IF(LMMS_BUILD_WIN32)
|
||||
SET(WANT_SNDIO OFF)
|
||||
SET(WANT_SOUNDIO OFF)
|
||||
SET(WANT_WINMM ON)
|
||||
SET(BUNDLE_QT_TRANSLATIONS ON)
|
||||
SET(LMMS_HAVE_WINMM TRUE)
|
||||
SET(STATUS_ALSA "<not supported on this platform>")
|
||||
SET(STATUS_JACK "<not supported on this platform>")
|
||||
@@ -165,6 +167,15 @@ IF(WANT_QT5)
|
||||
|
||||
# Resolve Qt5::qmake to full path for use in packaging scripts
|
||||
GET_TARGET_PROPERTY(QT_QMAKE_EXECUTABLE "${Qt5Core_QMAKE_EXECUTABLE}" IMPORTED_LOCATION)
|
||||
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_TRANSLATIONS
|
||||
OUTPUT_VARIABLE QT_TRANSLATIONS_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
IF(EXISTS "${QT_TRANSLATIONS_DIR}")
|
||||
MESSAGE("-- Found Qt translations in ${QT_TRANSLATIONS_DIR}")
|
||||
ADD_DEFINITIONS(-D'QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}"')
|
||||
ENDIF()
|
||||
|
||||
FIND_PACKAGE(Qt5Test)
|
||||
SET(QT_QTTEST_LIBRARY Qt5::Test)
|
||||
|
||||
@@ -48,9 +48,9 @@ FOREACH(_item ${qm_targets})
|
||||
ADD_DEPENDENCIES(finalize-locales "${_item}")
|
||||
ENDFOREACH(_item ${qm_targets})
|
||||
|
||||
IF(LMMS_BUILD_WIN32)
|
||||
FILE(GLOB QT_QM_FILES "${QT_TRANSLATIONS_DIR}/qt*[^h].qm")
|
||||
IF(BUNDLE_QT_TRANSLATIONS)
|
||||
FILE(GLOB QT_QM_FILES "${QT_TRANSLATIONS_DIR}/qt*.qm")
|
||||
LIST(SORT QT_QM_FILES)
|
||||
ENDIF(LMMS_BUILD_WIN32)
|
||||
ENDIF()
|
||||
|
||||
INSTALL(FILES ${QM_FILES} ${QT_QM_FILES} DESTINATION "${LMMS_DATA_DIR}/locale")
|
||||
|
||||
@@ -86,9 +86,10 @@ inline void loadTranslation( const QString & tname,
|
||||
QTranslator * t = new QTranslator( QCoreApplication::instance() );
|
||||
QString name = tname + ".qm";
|
||||
|
||||
t->load( name, dir );
|
||||
|
||||
QCoreApplication::instance()->installTranslator( t );
|
||||
if (t->load(name, dir))
|
||||
{
|
||||
QCoreApplication::instance()->installTranslator(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -651,19 +652,17 @@ int main( int argc, char * * argv )
|
||||
pos = QLocale::system().name().left( 2 );
|
||||
}
|
||||
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
#undef QT_TRANSLATIONS_DIR
|
||||
#define QT_TRANSLATIONS_DIR ConfigManager::inst()->localeDir()
|
||||
#endif
|
||||
|
||||
#ifdef QT_TRANSLATIONS_DIR
|
||||
// load translation for Qt-widgets/-dialogs
|
||||
loadTranslation( QString( "qt_" ) + pos,
|
||||
QString( QT_TRANSLATIONS_DIR ) );
|
||||
#endif
|
||||
// load actual translation for LMMS
|
||||
loadTranslation( pos );
|
||||
|
||||
// load translation for Qt-widgets/-dialogs
|
||||
#ifdef QT_TRANSLATIONS_DIR
|
||||
// load from the original path first
|
||||
loadTranslation(QString("qt_") + pos, QT_TRANSLATIONS_DIR);
|
||||
#endif
|
||||
// override it with bundled/custom one, if exists
|
||||
loadTranslation(QString("qt_") + pos, ConfigManager::inst()->localeDir());
|
||||
|
||||
|
||||
// try to set realtime priority
|
||||
#if defined(LMMS_BUILD_LINUX) || defined(LMMS_BUILD_FREEBSD)
|
||||
|
||||
Reference in New Issue
Block a user