diff --git a/cmake/KF5I18nMacros.cmake.in b/cmake/KF5I18nMacros.cmake.in --- a/cmake/KF5I18nMacros.cmake.in +++ b/cmake/KF5I18nMacros.cmake.in @@ -108,45 +108,53 @@ set(LOCALE_INSTALL_DIR share/locale) endif() + get_filename_component(absolute_podir ${podir} ABSOLUTE) + + # we try to find the po directory in the binary directory, in case it was downloaded + # using ECM + if (NOT (EXISTS "${absolute_podir}" AND IS_DIRECTORY "${absolute_podir}")) + get_filename_component(absolute_podir ${CMAKE_BINARY_DIR}/${podir} ABSOLUTE) + endif() + + if (NOT (EXISTS "${absolute_podir}" AND IS_DIRECTORY "${absolute_podir}")) + # Nothing to do if there's no podir and it would create an empty + # LOCALE_INSTALL_DIR in that case. + return() + endif() + get_filename_component(dirname ${LOCALE_INSTALL_DIR} NAME) get_filename_component(destname ${LOCALE_INSTALL_DIR} DIRECTORY) - - get_filename_component(absolute_podir ${podir} ABSOLUTE) string(MD5 pathmd5 ${absolute_podir}) - # Nothing to do if there's no podir and it would create an empty - # LOCALE_INSTALL_DIR in that case. - if (EXISTS "${absolute_podir}" AND IS_DIRECTORY "${absolute_podir}") - add_custom_target(pofiles-${pathmd5} ALL - COMMENT "Generating mo..." - COMMAND ${CMAKE_COMMAND} - -DGETTEXT_MSGFMT_EXECUTABLE=${GETTEXT_MSGFMT_EXECUTABLE} - -DCOPY_TO=${CMAKE_CURRENT_BINARY_DIR}/${dirname} - -DPO_DIR=${absolute_podir} - -P ${_ki18n_build_pofiles_script} - ) - add_custom_target(tsfiles-${pathmd5} ALL - COMMENT "Generating ts..." - COMMAND ${CMAKE_COMMAND} - -DPYTHON_EXECUTABLE=${KI18N_PYTHON_EXECUTABLE} - -D_ki18n_pmap_compile_script=${_ki18n_pmap_compile_script} - -DCOPY_TO=${CMAKE_CURRENT_BINARY_DIR}/${dirname} - -DPO_DIR=${absolute_podir} - -P ${_ki18n_build_tsfiles_script} - ) - - if (NOT TARGET pofiles) - add_custom_target(pofiles) - endif() - if (NOT TARGET tsfiles) - add_custom_target(tsfiles) - endif() - add_dependencies(pofiles pofiles-${pathmd5}) - add_dependencies(tsfiles tsfiles-${pathmd5}) - - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dirname}) - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dirname} DESTINATION ${destname}) + add_custom_target(pofiles-${pathmd5} ALL + COMMENT "Generating mo..." + COMMAND ${CMAKE_COMMAND} + -DGETTEXT_MSGFMT_EXECUTABLE=${GETTEXT_MSGFMT_EXECUTABLE} + -DCOPY_TO=${CMAKE_CURRENT_BINARY_DIR}/${dirname} + -DPO_DIR=${absolute_podir} + -P ${_ki18n_build_pofiles_script} + ) + add_custom_target(tsfiles-${pathmd5} ALL + COMMENT "Generating ts..." + COMMAND ${CMAKE_COMMAND} + -DPYTHON_EXECUTABLE=${KI18N_PYTHON_EXECUTABLE} + -D_ki18n_pmap_compile_script=${_ki18n_pmap_compile_script} + -DCOPY_TO=${CMAKE_CURRENT_BINARY_DIR}/${dirname} + -DPO_DIR=${absolute_podir} + -P ${_ki18n_build_tsfiles_script} + ) + + if (NOT TARGET pofiles) + add_custom_target(pofiles) endif() + if (NOT TARGET tsfiles) + add_custom_target(tsfiles) + endif() + add_dependencies(pofiles pofiles-${pathmd5}) + add_dependencies(tsfiles tsfiles-${pathmd5}) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dirname}) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dirname} DESTINATION ${destname}) endfunction() #install the scripts for a given language in the target folder diff --git a/src/kcatalog.cpp b/src/kcatalog.cpp --- a/src/kcatalog.cpp +++ b/src/kcatalog.cpp @@ -135,19 +135,23 @@ } } - QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("locale/") + relpath); - QString localeDir; - if (!file.isEmpty()) { #if defined(Q_OS_ANDROID) - // The exact file name must be returned on Android because libintl-lite loads a catalog by filename with bindtextdomain() - localeDir = file; +// The exact file name must be returned on Android because libintl-lite loads a catalog by filename with bindtextdomain() + QString file = QDir::homePath()+QStringLiteral("/../qt-reserved-files/share/locale/") + relpath; + if (!QFile::exists(file)) { + file.clear(); + } + return file; #else + const QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("locale/") + relpath); + + QString localeDir; + if (!file.isEmpty()) { // Path of the locale/ directory must be returned. localeDir = QFileInfo(file.left(file.size() - relpath.size())).absolutePath(); -#endif } return localeDir; +#endif } QSet KCatalog::availableCatalogLanguages(const QByteArray &domain_)