Merge branch 'issue-1495' into calamares

Drop the pre-compiled .mo translations from the sources;
these can be built during the build.

FIXES #1495
main
Adriaan de Groot 5 years ago
commit 8352be8bf5

@ -83,17 +83,3 @@ Copyright: 2020 Calamares authors and translators
Files: src/modules/dummypythonqt/lang/*/LC_MESSAGES/dummypythonqt.po
License: GPL-3.0-or-later
Copyright: 2020 Calamares authors and translators
### FIXME ISSUES
#
# The .mo files are build artifacts
#
# FIXME: these shouldn't be in the source repo at all
#
Files: lang/python/*/LC_MESSAGES/python.mo
License: GPL-3.0-or-later
Copyright: 2020 Calamares authors and translators
Files: src/modules/dummypythonqt/lang/*/LC_MESSAGES/dummypythonqt.mo
License: GPL-3.0-or-later
Copyright: 2020 Calamares authors and translators

@ -12,57 +12,14 @@
include( CMakeParseArguments )
# Internal macro for adding the C++ / Qt translations to the
# build and install tree. Should be called only once, from
# src/calamares/CMakeLists.txt.
macro(add_calamares_translations language)
list( APPEND CALAMARES_LANGUAGES ${ARGV} )
set( calamares_i18n_qrc_content "" )
# calamares and qt language files
foreach( lang ${CALAMARES_LANGUAGES} )
foreach( tlsource "calamares_${lang}" "tz_${lang}" )
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<file>${tlsource}.qm</file>\n" )
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
endif()
endforeach()
endforeach()
set( trans_file calamares_i18n )
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
qt5_add_translation(QM_FILES ${TS_FILES})
# Run the resource compiler (rcc_options should already be set)
add_custom_command(
OUTPUT ${trans_outfile}
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES}
)
endmacro()
# Internal macro for Python translations
#
# Translations of the Python modules that don't have their own
# lang/ subdirectories -- these are collected in top-level
# lang/python/<lang>/LC_MESSAGES/python.mo
macro(add_calamares_python_translations language)
set( CALAMARES_LANGUAGES "" )
list( APPEND CALAMARES_LANGUAGES ${ARGV} )
install_calamares_gettext_translations( python
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lang/python
FILENAME python.mo
RENAME calamares-python.mo
)
endmacro()
# The Gettext module is still old-fashioned, ALLCAPS variables
find_package( Gettext )
set_package_properties( GETTEXT PROPERTIES
DESCRIPTION "GNU gettext (translation) tools."
URL "https://www.gnu.org/software/gettext/"
PURPOSE "Gettext is used in the translation of Python modules."
TYPE REQUIRED
)
# Installs a directory containing language-code-labeled subdirectories with
# gettext data into the appropriate system directory. Allows renaming the
@ -94,31 +51,52 @@ function( install_calamares_gettext_translations )
if( NOT TRANSLATION_RENAME )
set( TRANSLATION_RENAME "${TRANSLATION_FILENAME}" )
endif()
string( REGEX REPLACE ".mo$" ".po" TRANSLATION_SOURCE_FILENAME "${TRANSLATION_FILENAME}" )
message(STATUS "Installing gettext translations for ${TRANSLATION_NAME}")
message(STATUS " Installing ${TRANSLATION_FILENAME} from ${TRANSLATION_SOURCE_DIR}")
if ( GETTEXT_FOUND AND GETTEXT_MSGFMT_EXECUTABLE )
message( STATUS "Installing gettext translations for ${TRANSLATION_NAME}")
message( STATUS " Installing ${TRANSLATION_FILENAME} from ${TRANSLATION_SOURCE_DIR}")
else()
message( WARNING "Gettext translations requested for ${TRANSLATION_NAME}, but gettext was not found." )
return()
endif()
set( TARGET_NAME calamares-gettext-translations-${NAME} )
if( NOT TARGET "${TARGET_NAME}" )
add_custom_target( "${TARGET_NAME}" ALL )
endif()
set( TRANSLATION_NAME "${NAME}" )
set( INSTALLED_TRANSLATIONS "" )
foreach( lang ${CALAMARES_TRANSLATION_LANGUAGES} ) # Global
set( lang_mo "${TRANSLATION_SOURCE_DIR}/${lang}/LC_MESSAGES/${TRANSLATION_FILENAME}" )
string( MAKE_C_IDENTIFIER "${TARGET_NAME}-${lang}" TARGET_SUBNAME )
set( lang_po "${TRANSLATION_SOURCE_DIR}/${lang}/LC_MESSAGES/${TRANSLATION_SOURCE_FILENAME}" )
set( lang_mo_dir "${CMAKE_BINARY_DIR}/lang/${lang}/LC_MESSAGES" )
set( lang_mo "${lang_mo_dir}/${TRANSLATION_RENAME}" )
if( lang STREQUAL "en" )
message( STATUS " Skipping ${TRANSLATION_NAME} translations for en_US" )
else( EXISTS ${lang_mo} )
list( APPEND INSTALLED_LANGUAGES "${lang}" )
else()
# We **don't** use the gettext macro's here because the source
# structure doesn't match: we are calling this once per language
# for all of Calamares's languages, while the gettext module
# expects it to be called once, for a given language source-dir.
#
# Using any of the gettext macros just gets us multiple rules
# for python.gmo, and it wants to use msgmerge, besides, which
# doesn't fit our Transifex workflow.
make_directory( ${lang_mo_dir} )
add_custom_command(
OUTPUT ${lang_mo}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
ARGS -o ${lang_mo} ${lang_po}
MAIN_DEPENDENCY ${lang_po}
)
add_custom_target( "${TARGET_SUBNAME}" DEPENDS ${lang_mo} )
add_dependencies( "${TARGET_NAME}" "${TARGET_SUBNAME}" )
install(
FILES ${lang_mo}
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES/
RENAME ${TRANSLATION_RENAME}
)
# TODO: make translations available in build dir too, for
# translation when running calamares -d from builddir.
set(_build_lc ${CMAKE_BINARY_DIR}/lang/${lang}/LC_MESSAGES/)
file(COPY ${lang_mo} DESTINATION ${_build_lc})
if (NOT TRANSLATION_FILENAME STREQUAL TRANSLATION_RENAME)
file(RENAME ${_build_lc}${TRANSLATION_FILENAME} ${_build_lc}${TRANSLATION_RENAME})
endif()
endif()
endforeach()
endfunction()

@ -126,7 +126,7 @@ for MODULE_DIR in $(find src/modules -maxdepth 1 -mindepth 1 -type d) ; do
# Convert PO files to MO files
for POFILE in $(find ${MODULE_DIR} -name "*.po") ; do
sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' $POFILE
msgfmt -o ${POFILE%.po}.mo $POFILE
# msgfmt -o ${POFILE%.po}.mo $POFILE
done
git add --verbose ${MODULE_DIR}/lang/*
git commit "$AUTHOR" --message="i18n: [${MODULE_NAME}] $BOILERPLATE" | true
@ -136,7 +136,7 @@ done
for POFILE in $(find lang -name "python.po") ; do
sed -i'' '/^"Content-Type/s/CHARSET/UTF-8/' $POFILE
msgfmt -o ${POFILE%.po}.mo $POFILE
# msgfmt -o ${POFILE%.po}.mo $POFILE
done
git add --verbose lang/python*
git commit "$AUTHOR" --message="i18n: [python] $BOILERPLATE" | true

@ -5,8 +5,16 @@
#
###
include( CalamaresAddTranslations )
find_package(Qt5 COMPONENTS Xml)
if( Qt5Xml_FOUND )
add_executable(txload txload.cpp)
target_link_libraries(txload Qt5::Xml)
endif()
install_calamares_gettext_translations( python
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lang/python
FILENAME python.mo
RENAME calamares-python.mo
)

@ -3,11 +3,12 @@
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
# SPDX-License-Identifier: BSD-2-Clause
#
include( CalamaresAddPlugin )
include( CalamaresAddModuleSubdirectory )
include( CalamaresAddLibrary )
include( CalamaresAddBrandingSubdirectory )
include( CalamaresAddLibrary )
include( CalamaresAddModuleSubdirectory )
include( CalamaresAddPlugin )
include( CalamaresAddTest )
include( CalamaresAddTranslations )
# library
add_subdirectory( libcalamares )

@ -4,8 +4,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# "calamares_bin" is the main application, not to be confused with
# the target "calamares" which is the non-GUI library part.
set( calamaresSources
main.cpp
CalamaresApplication.cpp
@ -36,10 +34,44 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
# Translations
include( CalamaresAddTranslations )
add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )
### TRANSLATIONS
#
#
set( TS_FILES "" )
set( calamares_i18n_qrc_content "" )
# calamares and qt language files
foreach( lang ${CALAMARES_LANGUAGES} )
foreach( tlsource "calamares_${lang}" "tz_${lang}" )
if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<file>${tlsource}.qm</file>\n" )
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" )
endif()
endforeach()
endforeach()
set( trans_file calamares_i18n )
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )
configure_file( ${CMAKE_SOURCE_DIR}/lang/calamares_i18n.qrc.in ${trans_infile} @ONLY )
qt5_add_translation(QM_FILES ${TS_FILES})
# Run the resource compiler (rcc_options should already be set)
add_custom_command(
OUTPUT ${trans_outfile}
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
ARGS ${rcc_options} --format-version 1 -name ${trans_file} -o ${trans_outfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES}
)
### EXECUTABLE
#
# "calamares_bin" is the main application, not to be confused with
# the target "calamares" which is the non-GUI library part.
#
add_executable( calamares_bin ${calamaresSources} calamares.qrc ${trans_outfile} )
target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} )
set_target_properties(calamares_bin
@ -82,6 +114,9 @@ install( FILES ${CMAKE_SOURCE_DIR}/data/images/squid.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps
)
### TESTS
#
#
if( BUILD_TESTING )
# Don't install, these are just for enable_testing
add_executable( loadmodule testmain.cpp )

@ -73,9 +73,6 @@ foreach( _category ${_use_categories} )
endif()
endforeach()
include( CalamaresAddTranslations )
add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )
# TODO:3.3: Use FindPython3
if ( BUILD_TESTING AND BUILD_SCHEMA_TESTING AND PYTHONINTERP_FOUND AND PYTHON_EXECUTABLE )
# The tests for each config file are independent of whether the

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save