diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index d6830867c19e1a..8efee32649b96f 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -135,6 +135,7 @@ ENDMACRO(GETTEXT_CREATE_TRANSLATIONS ) ADD_SUBDIRECTORY(stellarium) +ADD_SUBDIRECTORY(stellarium-sky) ADD_SUBDIRECTORY(stellarium-skycultures) ADD_SUBDIRECTORY(stellarium-planetary-features) IF(ENABLE_SCRIPTING) diff --git a/po/stellarium-skycultures/CMakeLists.txt b/po/stellarium-skycultures/CMakeLists.txt index 7e298547c3fa13..7aa683556bb042 100644 --- a/po/stellarium-skycultures/CMakeLists.txt +++ b/po/stellarium-skycultures/CMakeLists.txt @@ -2,4 +2,35 @@ FILE(GLOB poscfiles RELATIVE "${CMAKE_SOURCE_DIR}/po/stellarium-skycultures/" "* LIST(SORT poscfiles) STRING(REGEX REPLACE ".po" "" outposcfiles "${poscfiles}") -GETTEXT_CREATE_TRANSLATIONS(stellarium-skycultures DEFAULT_TARGET ${outposcfiles}) +# This is a copy of the implementation of GETTEXT_CREATE_TRANSLATIONS, but +# without updating the .po or .pot files, because they are made by an external +# script from a separate repository. +set(_domain stellarium-skycultures) + +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/translations/${_domain}) + +SET(_gmoFiles) + +SET(_addToAll "ALL") + +FOREACH (_lang ${outposcfiles}) + GET_FILENAME_COMPONENT(_absFile ${_lang}.po ABSOLUTE) + FILE(RELATIVE_PATH _relFile ${PROJECT_SOURCE_DIR} ${_absFile}) + SET(_gmoFile ${CMAKE_BINARY_DIR}/translations/${_domain}/${_lang}.qm) + + # Convert a PO file into a qm file. + ADD_CUSTOM_COMMAND( + OUTPUT ${_gmoFile} + COMMAND ${lconvert_executable} -i ${_absFile} -o ${_gmoFile} + DEPENDS ${_absFile} + ) + + INSTALL(FILES ${_gmoFile} DESTINATION ${SDATALOC}/translations/${_domain}/) + SET(_gmoFiles ${_gmoFiles} ${_gmoFile}) +ENDFOREACH (_lang) + +# Create the .qm files when building the "translations-" and +# "translations" targets. +ADD_CUSTOM_TARGET(translations-${_domain} ${_addToAll} DEPENDS ${_gmoFiles}) +ADD_DEPENDENCIES(translations translations-${_domain}) +SET_TARGET_PROPERTIES(translations-${_domain} PROPERTIES FOLDER "po") diff --git a/src/core/StelTranslator.cpp b/src/core/StelTranslator.cpp index dc46b2b394163b..3bf4348ab12586 100644 --- a/src/core/StelTranslator.cpp +++ b/src/core/StelTranslator.cpp @@ -207,22 +207,12 @@ void StelTranslator::initIso639_1LanguageCodes(const QString& fileName) } } -static constexpr char skyCulturePrefix[] = "stellarium-skycultures-"; StelSkyTranslator::StelSkyTranslator(const QString& skyCultureId, const QString& langName) - : commonSkyTranslator("stellarium-skycultures", langName) + : StelTranslator("stellarium-sky", langName) + , commonSkyTranslator("stellarium-skycultures", langName) { - domain = skyCulturePrefix + skyCultureId; - this->langName = langName; - translator = new QTranslator(); - - const auto path = StelFileMgr::getInstallationDir() + "/skycultures/" + skyCultureId + "/translations/" + getTrueLocaleName()+".qm"; - const bool res = translator->load(path); - if (!res) - qWarning() << "Couldn't load sky translations for language" << getTrueLocaleName() << "in sky culture" << skyCultureId; - if (translator->isEmpty()) - qWarning() << "Empty translation file for language " << getTrueLocaleName() << "in sky culture" << skyCultureId; if (commonSkyTranslator.isEmpty()) - qWarning() << "Empty skyculture-independent translation file for language " << getTrueLocaleName() << "in sky culture" << skyCultureId; + qWarning() << "Empty skyculture-independent translation file for language " << getTrueLocaleName(); } QString StelSkyTranslator::tryQtranslate(const QString& s, const QString& c) const