1
0
mirror of https://git.familie-radermacher.ch/linux/ptouch-print.git synced 2025-11-20 20:32:05 +00:00

fix gettext.cmake

This commit is contained in:
Dominic Radermacher
2025-08-03 14:21:56 +02:00
parent d1eeacbdd8
commit d7d97eede8
4 changed files with 333 additions and 157 deletions

View File

@@ -1,17 +1,15 @@
# Utilize gettext multilingual internationalization services
if(Gettext_FOUND)
add_custom_target(
pot-update
ALL
DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot
)
add_dependencies(pot-update git-version)
# generate pot files using xgettext
find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
if(GETTEXT_XGETTEXT_EXECUTABLE)
add_custom_target(
pot-update
ALL
DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot
)
file(GLOB_RECURSE C_FILES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/*.c)
file(STRINGS ${CMAKE_BINARY_DIR}/version.h VERSION_LINE REGEX "VERSION")
string(REGEX MATCH "\".*\"$" PVERSION ${VERSION_LINE})
add_custom_command(
TARGET pot-update
PRE_BUILD
@@ -20,40 +18,38 @@ if(Gettext_FOUND)
--keyword=N_
--force-po
--package-name=${PROJECT_NAME}
--package-version=${PVERSION}
--copyright-holder="Dominic Radermacher <dominic@familie-radermacher.ch>"
--msgid-bugs-address="dominic@familie-radermacher.ch"
--output ${CMAKE_SOURCE_DIR}/po/ptouch.pot
${C_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
else()
message(DEBUG "Variable GETTEXT_XGETTEXT_EXECUTABLE not set")
endif()
# read available languages from LINGUAS file while ignoring comments
file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]")
# read available languages from LINGUAS file while ignoring comments
file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]")
# merge po files
if(GETTEXT_MSGMERGE_EXECUTABLE)
add_custom_target(
po-merge
ALL
DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot
)
add_dependencies(po-merge pot-update)
foreach(LINGUA IN LISTS LINGUAS)
add_custom_command(
TARGET po-merge
PRE_BUILD
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE}
--update
--quiet
${CMAKE_SOURCE_DIR}/po/${LINGUA}.po
${CMAKE_SOURCE_DIR}/po/ptouch.pot
# merge po files
find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
if(GETTEXT_MSGMERGE_EXECUTABLE)
add_custom_target(
po-merge
ALL
DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot
)
endforeach()
add_dependencies(po-merge pot-update)
foreach(LINGUA IN LISTS LINGUAS)
add_custom_command(
TARGET po-merge
PRE_BUILD
COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE}
--update
--quiet
${CMAKE_SOURCE_DIR}/po/${LINGUA}.po
${CMAKE_SOURCE_DIR}/po/ptouch.pot
)
endforeach()
endif()
endif()
# compile po files