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 ${LYX_PROJECT})
14 macro(add_gettext_python _par _dir)
17 file(GLOB _s1 ${TOP_SRC_DIR}/${_dir}/${_arg})
19 list(APPEND _sources ${_s1})
21 SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
22 SET(_tmp_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_tmp_files")
23 SET(_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_files")
24 file(WRITE ${_tmp_src_files} "")
25 foreach(_s ${_sources})
26 FILE(APPEND ${_tmp_src_files} "${_s}\n")
28 if(${_par} MATCHES "^\(.*\)_[0-9]+$")
29 set(_par1 ${CMAKE_MATCH_1})
35 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_tmp_src_files} ${_src_files}
36 DEPENDS ${_tmp_src_files}
41 COMMAND ${LYX_PYTHON_EXECUTABLE}
42 ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
43 DEPENDS ${_sources} ${_src_files}
45 SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
46 SET_SOURCE_FILES_PROPERTIES("${_src_files}" GENERATED)
47 LIST(APPEND _py_sources "${_dst}")
48 endmacro(add_gettext_python)
50 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
51 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
52 SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
54 add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
55 add_gettext_python(layouts lib/layouts *.layout *.inc *.module)
56 add_gettext_python(languages lib languages)
57 add_gettext_python(encodings lib encodings)
58 add_gettext_python(ui lib/ui *.ui *.inc)
59 add_gettext_python(external lib external_templates)
60 add_gettext_python(formats lib configure.py)
63 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
64 COMMAND ${LYX_PYTHON_EXECUTABLE}
65 ARGS "${CMAKE_SOURCE_DIR}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
66 DEPENDS ${_py_sources}
70 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
71 COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
72 ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
73 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
78 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
79 file(GLOB_RECURSE _tmp_potfiles RELATIVE ${TOP_SRC_DIR}/ ${TOP_SRC_DIR}/src/*.h ${TOP_SRC_DIR}/src/*.cpp ${TOP_SRC_DIR}/src/*.cpp.in)
80 list(SORT _tmp_potfiles)
81 list(REMOVE_ITEM _tmp_potfiles src/support/Package.cpp)
83 foreach(_f ${_tmp_potfiles})
84 # we don't need to select only relevant files because the outcome of xgettext
86 # Relevant files are files containing the string '_(".*")'
87 LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
88 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
92 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
93 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
94 COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
95 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"
96 DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
100 # We have to copy the po-files first,
101 # otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
102 # This makes the "svn up" on po-files work again
103 file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
105 SET(LYX_UPDATED_PO_FILES)
106 SET(LYX_DEST_PO ${TOP_SRC_DIR}/po)
108 foreach(_pofile ${LYX_BASE_PO_FILES})
110 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
111 COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
112 DEPENDS ${TOP_SRC_DIR}/po/${_pofile}
114 list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
117 foreach(_pofile ${LYX_BASE_PO_FILES})
119 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}.copied
120 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${_pofile} ${LYX_DEST_PO}/${_pofile}
121 COMMAND ${CMAKE_COMMAND} -E touch ${_pofile}.copied
122 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
124 list(APPEND LYX_UPDATED_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}.copied)
128 set(_addALLOption ALL)
130 GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ${__addALLOption} ${LYX_PO_FILES})
132 # ALL omitted here, to prevent from automatic creation
133 ADD_CUSTOM_TARGET(update_po_files DEPENDS ${LYX_UPDATED_PO_FILES})
134 add_dependencies(update_po_files translations)