1 # This file is part of LyX, the document processor.
2 # Licence details can be found in the file COPYING.
4 # Copyright (c) 2008, 2009 Peter Kümmel, <syntheticpp@gmx.net>
5 # Copyright (c) 2008, 2009 Kornel Benko, <Kornel.Benko@berlin.de>
10 include_directories(${TOP_SRC_DIR}/po)
12 SET(_lyxname ${PACKAGE})
14 macro(add_gettext_python _par _dir)
15 file(GLOB _sources ${TOP_SRC_DIR}/${_dir}/${ARGN})
16 SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
21 ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par} ${_sources}
24 SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
25 LIST(APPEND _py_sources "${_dst}")
26 endmacro(add_gettext_python)
28 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
29 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
30 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
32 add_gettext_python(encodings lib encodings)
33 add_gettext_python(external lib external_templates)
34 add_gettext_python(formats lib configure.py)
35 add_gettext_python(languages lib languages)
36 add_gettext_python(layouts lib/layouts *.layouts *.inc *.module)
37 add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
38 add_gettext_python(ui lib/ui *.ui *.inc)
40 FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
41 FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
44 # We need here perl, because I don't know how
45 # to write the alternative for "cat" in python
46 # e.g. perl -e "\"while(<>){print;}\""
47 # But maybe Jose knows?
50 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
52 ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
53 DEPENDS ${_py_sources}
57 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
58 COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
59 ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
60 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
65 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
66 foreach(_dir src src/frontends/qt4 src/insets src/mathed src/support src/tex2lyx)
67 file(GLOB _tmp_potfiles RELATIVE ${TOP_SRC_DIR} ${TOP_SRC_DIR}/${_dir}/*.cpp)
68 foreach(_f ${_tmp_potfiles})
69 LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
70 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
75 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
76 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
77 COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
78 ARGS --default-domain=${_lyxname} --directory=${TOP_SRC_DIR} --add-comments=TRANSLATORS: --language=C++ --join-existing --keyword=_ --keyword=N_ --keyword=B_ --keyword=qt_ --files-from="${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in" --copyright-holder='LyX Developers' --msgid-bugs-address=lyx-devel@lists.lyx.org -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
79 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
83 # We have to copy the po-files first,
84 # otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
85 # This makes the "svn up" on po-files work again
86 file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
88 foreach(_pofile ${LYX_BASE_PO_FILES})
89 configure_file(${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile} COPYONLY)
90 list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
93 GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ALL ${LYX_PO_FILES})