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")
21 SET(_tmp_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_tmp_files")
22 SET(_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_files")
23 file(WRITE ${_tmp_src_files} "")
24 foreach(_s ${_sources})
25 FILE(APPEND ${_tmp_src_files} "${_s}\n")
27 if(${_par} MATCHES "^\(.*\)_[0-9]+$")
28 set(_par1 ${CMAKE_MATCH_1})
34 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_tmp_src_files} ${_src_files}
35 DEPENDS ${_tmp_src_files}
41 ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
42 DEPENDS ${_sources} ${_src_files}
44 SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
45 SET_SOURCE_FILES_PROPERTIES("${_src_files}" GENERATED)
46 LIST(APPEND _py_sources "${_dst}")
47 endmacro(add_gettext_python)
49 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
50 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
51 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
53 add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
54 add_gettext_python(layouts lib/layouts *.layout *.inc *.module)
55 add_gettext_python(languages lib languages)
56 add_gettext_python(encodings lib encodings)
57 add_gettext_python(ui lib/ui *.ui *.inc)
58 add_gettext_python(external lib external_templates)
59 add_gettext_python(formats lib configure.py)
61 FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
62 FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
65 # We need here perl, because I don't know how
66 # to write the alternative for "cat" in python
67 # e.g. perl -e "\"while(<>){print;}\""
68 # But maybe Jose knows?
71 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
72 COMMAND ${_PERL_EXECUTABLE}
73 ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
74 DEPENDS ${_py_sources}
78 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
79 COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
80 ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
81 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
86 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
87 foreach(_dir src/frontends/qt4 src/insets src/mathed src/support src/tex2lyx src)
88 file(GLOB _tmp_potfiles RELATIVE ${TOP_SRC_DIR} ${TOP_SRC_DIR}/${_dir}/*.cpp)
89 list(SORT _tmp_potfiles)
90 foreach(_f ${_tmp_potfiles})
91 LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
92 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
97 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
98 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
99 COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
100 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"
101 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
105 # We have to copy the po-files first,
106 # otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
107 # This makes the "svn up" on po-files work again
108 file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
110 foreach(_pofile ${LYX_BASE_PO_FILES})
112 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
113 COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
114 DEPENDS ${TOP_SRC_DIR}/po/${_pofile}
116 list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
119 GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ALL ${LYX_PO_FILES})