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)
17 file(GLOB _s1 ${TOP_SRC_DIR}/${_dir}/${_arg})
18 list(APPEND _sources ${_s1})
20 SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
25 ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par} ${_sources}
28 SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
29 LIST(APPEND _py_sources "${_dst}")
30 endmacro(add_gettext_python)
32 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
33 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
34 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
36 add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
37 add_gettext_python(layouts lib/layouts *.layout *.inc *.module)
38 add_gettext_python(languages lib languages)
39 add_gettext_python(encodings lib encodings)
40 add_gettext_python(ui lib/ui *.ui *.inc)
41 add_gettext_python(external lib external_templates)
42 add_gettext_python(formats lib configure.py)
44 FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
45 FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
48 # We need here perl, because I don't know how
49 # to write the alternative for "cat" in python
50 # e.g. perl -e "\"while(<>){print;}\""
51 # But maybe Jose knows?
54 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
56 ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
57 DEPENDS ${_py_sources}
61 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
62 COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
63 ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
64 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
69 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
70 foreach(_dir src/frontends/qt4 src/insets src/mathed src/support src/tex2lyx src)
71 file(GLOB _tmp_potfiles RELATIVE ${TOP_SRC_DIR} ${TOP_SRC_DIR}/${_dir}/*.cpp)
72 foreach(_f ${_tmp_potfiles})
73 LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
74 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
79 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
80 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
81 COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
82 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"
83 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
87 # We have to copy the po-files first,
88 # otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
89 # This makes the "svn up" on po-files work again
90 file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
92 foreach(_pofile ${LYX_BASE_PO_FILES})
94 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
95 COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
96 DEPENDS ${TOP_SRC_DIR}/po/${_pofile}
98 list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
101 GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ALL ${LYX_PO_FILES})