mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-08-16 00:25:53 +00:00
better gettext support (thanks to Michael Schulz)
This commit is contained in:
parent
1f450d9124
commit
efa48162a8
@ -37,7 +37,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
|
|||||||
|
|
||||||
target_sources(${PROJECT_NAME} PRIVATE
|
target_sources(${PROJECT_NAME} PRIVATE
|
||||||
include/ptouch.h
|
include/ptouch.h
|
||||||
include/gettext.h
|
|
||||||
src/libptouch.c
|
src/libptouch.c
|
||||||
src/ptouch-print.c
|
src/ptouch-print.c
|
||||||
)
|
)
|
||||||
@ -66,6 +65,8 @@ add_custom_target(git-version ALL
|
|||||||
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake
|
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gettext.cmake)
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||||
|
76
cmake/gettext.cmake
Normal file
76
cmake/gettext.cmake
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# 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
|
||||||
|
if(GETTEXT_XGETTEXT_EXECUTABLE)
|
||||||
|
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
|
||||||
|
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
|
||||||
|
--keyword=_
|
||||||
|
--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 "^[^#]")
|
||||||
|
|
||||||
|
# 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
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# compile po files
|
||||||
|
foreach(LINGUA IN LISTS LINGUAS)
|
||||||
|
gettext_process_po_files(
|
||||||
|
${LINGUA}
|
||||||
|
ALL
|
||||||
|
PO_FILES ${CMAKE_SOURCE_DIR}/po/${LINGUA}.po
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# install mo files
|
||||||
|
foreach(LINGUA IN LISTS LINGUAS)
|
||||||
|
install(
|
||||||
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}.gmo"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${LINGUA}/LC_MESSAGES"
|
||||||
|
RENAME "${PROJECT_NAME}.mo"
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
5
po/de.po
5
po/de.po
@ -56,7 +56,8 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/libptouch.c:158
|
#: src/libptouch.c:158
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "No P-Touch printer found on USB (remember to put switch to position E)\n"
|
msgid ""
|
||||||
|
"No P-Touch printer found on USB (remember to put switch to position E)\n"
|
||||||
msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n"
|
msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n"
|
||||||
|
|
||||||
#: src/libptouch.c:178
|
#: src/libptouch.c:178
|
||||||
@ -66,7 +67,6 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/libptouch.c:182
|
#: src/libptouch.c:182
|
||||||
#, fuzzy, c-format
|
#, fuzzy, c-format
|
||||||
#| msgid "read error: got %i instead of 32 bytes\n"
|
|
||||||
msgid "write error: could send only %i of %ld bytes\n"
|
msgid "write error: could send only %i of %ld bytes\n"
|
||||||
msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n"
|
msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n"
|
||||||
|
|
||||||
@ -152,7 +152,6 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/ptouch-print.c:133
|
#: src/ptouch-print.c:133
|
||||||
#, fuzzy, c-format
|
#, fuzzy, c-format
|
||||||
#| msgid "ptouch_send() failed\n"
|
|
||||||
msgid "ptouch_sendraster() failed\n"
|
msgid "ptouch_sendraster() failed\n"
|
||||||
msgstr "ptouch_send() fehlgeschlagen\n"
|
msgstr "ptouch_send() fehlgeschlagen\n"
|
||||||
|
|
||||||
|
7
po/en.po
7
po/en.po
@ -55,8 +55,10 @@ msgstr "interface claim error: %s\n"
|
|||||||
|
|
||||||
#: src/libptouch.c:158
|
#: src/libptouch.c:158
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "No P-Touch printer found on USB (remember to put switch to position E)\n"
|
msgid ""
|
||||||
msgstr "No P-Touch printer found on USB (remember to put switch to position E)\n"
|
"No P-Touch printer found on USB (remember to put switch to position E)\n"
|
||||||
|
msgstr ""
|
||||||
|
"No P-Touch printer found on USB (remember to put switch to position E)\n"
|
||||||
|
|
||||||
#: src/libptouch.c:178
|
#: src/libptouch.c:178
|
||||||
#, c-format
|
#, c-format
|
||||||
@ -65,7 +67,6 @@ msgstr "write error: %s\n"
|
|||||||
|
|
||||||
#: src/libptouch.c:182
|
#: src/libptouch.c:182
|
||||||
#, fuzzy, c-format
|
#, fuzzy, c-format
|
||||||
#| msgid "write error: could send only %i of %i bytes\n"
|
|
||||||
msgid "write error: could send only %i of %ld bytes\n"
|
msgid "write error: could send only %i of %ld bytes\n"
|
||||||
msgstr "write error: could send only %i of %i bytes\n"
|
msgstr "write error: could send only %i of %i bytes\n"
|
||||||
|
|
||||||
|
@ -535,7 +535,11 @@ int main(int argc, char *argv[])
|
|||||||
ptouch_dev ptdev = NULL;
|
ptouch_dev ptdev = NULL;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain("ptouch-print", "/usr/share/locale/");
|
const char *textdomain_dir = getenv("TEXTDOMAINDIR");
|
||||||
|
if (!textdomain_dir) {
|
||||||
|
textdomain_dir = "/usr/share/locale/";
|
||||||
|
}
|
||||||
|
bindtextdomain("ptouch-print", textdomain_dir);
|
||||||
textdomain("ptouch-print");
|
textdomain("ptouch-print");
|
||||||
int i = parse_args(argc, argv);
|
int i = parse_args(argc, argv);
|
||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user