Load translations of dependencies, too
This commit is contained in:
parent
783c00b78c
commit
aca86b0681
|
@ -114,7 +114,7 @@ set(META_APP_AUTHOR "Martchus")
|
|||
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
||||
set(META_APP_DESCRIPTION "Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models")
|
||||
set(META_VERSION_MAJOR 5)
|
||||
set(META_VERSION_MINOR 3)
|
||||
set(META_VERSION_MINOR 4)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||
|
||||
|
@ -158,7 +158,7 @@ else()
|
|||
endif()
|
||||
|
||||
# find c++utilities
|
||||
find_package(c++utilities 4.0.0 REQUIRED)
|
||||
find_package(c++utilities 4.5.0 REQUIRED)
|
||||
use_cpp_utilities()
|
||||
|
||||
# include modules to apply configuration
|
||||
|
|
|
@ -110,6 +110,7 @@ list_to_string(", " "QStringLiteral(\"" "\")" "${QT_TRANSLATION_FILES}" QT_TRANS
|
|||
# enable lrelease and add install target for localization
|
||||
if(TS_FILES)
|
||||
message(STATUS "Project has translations which will be released.")
|
||||
set(APP_SPECIFIC_QT_TRANSLATIONS_AVAILABLE YES)
|
||||
|
||||
# the LinguistTools module is required
|
||||
# (but not add it to QT_MODULES because we don't link against it)
|
||||
|
@ -137,6 +138,10 @@ if(TS_FILES)
|
|||
add_dependencies(${LOCALIZATION_TARGET} ${META_PROJECT_NAME}_translations)
|
||||
endif()
|
||||
|
||||
# make application specific translation available as array via config.h
|
||||
list(APPEND APP_SPECIFIC_QT_TRANSLATION_FILES "${META_PROJECT_NAME}")
|
||||
list_to_string(", " "QStringLiteral(\"" "\")" "${APP_SPECIFIC_QT_TRANSLATION_FILES}" APP_SPECIFIC_QT_TRANSLATION_FILES_ARRAY)
|
||||
|
||||
# built-in translations
|
||||
if(BUILTIN_TRANSLATIONS)
|
||||
# write a qrc file for the qm files and add it to the resource files
|
||||
|
@ -149,6 +154,9 @@ if(TS_FILES)
|
|||
file(APPEND "${TRANSLATIONS_QRC_FILE}" "</qresource></RCC>")
|
||||
list(APPEND RES_FILES "${TRANSLATIONS_QRC_FILE}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
set(APP_SPECIFIC_QT_TRANSLATIONS_AVAILABLE NO)
|
||||
endif()
|
||||
|
||||
# generate DBus interfaces
|
||||
|
|
|
@ -180,6 +180,20 @@ void loadApplicationTranslationFile(const QString &applicationName, const QStrin
|
|||
}
|
||||
}
|
||||
|
||||
void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames)
|
||||
{
|
||||
for(const QString &applicationName : applicationNames) {
|
||||
loadApplicationTranslationFile(applicationName);
|
||||
}
|
||||
}
|
||||
|
||||
void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames, const QString &localeName)
|
||||
{
|
||||
for(const QString &applicationName : applicationNames) {
|
||||
loadApplicationTranslationFile(applicationName, localeName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -21,11 +21,11 @@ QT_FORWARD_DECLARE_CLASS(QSettings)
|
|||
QCoreApplication::setApplicationVersion(QStringLiteral(APP_VERSION))
|
||||
|
||||
/*!
|
||||
* \brief Loads translations for Qt and the application.
|
||||
* \brief Loads translations for Qt, other dependencies and the application.
|
||||
*/
|
||||
#define LOAD_QT_TRANSLATIONS \
|
||||
TranslationFiles::loadQtTranslationFile(QT_TRANSLATION_FILES); \
|
||||
TranslationFiles::loadApplicationTranslationFile(QStringLiteral(PROJECT_NAME))
|
||||
TranslationFiles::loadApplicationTranslationFile(APP_SPECIFIC_QT_TRANSLATION_FILES)
|
||||
|
||||
namespace QtUtilitiesResources {
|
||||
|
||||
|
@ -41,6 +41,8 @@ QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> re
|
|||
QT_UTILITIES_EXPORT void loadQtTranslationFile(std::initializer_list<QString> repositoryNames, const QString &localeName);
|
||||
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName);
|
||||
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const QString &applicationName, const QString &localeName);
|
||||
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames);
|
||||
QT_UTILITIES_EXPORT void loadApplicationTranslationFile(const std::initializer_list<QString> &applicationNames, const QString &localeName);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue