2008-12-28 13:35:29 +00:00
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
# Licence details can be found in the file COPYING.
|
|
|
|
#
|
2009-01-06 18:51:00 +00:00
|
|
|
# Copyright (c) 2008, 2009 Peter Kümmel, <syntheticpp@gmx.net>
|
|
|
|
# Copyright (c) 2008, 2009 Kornel Benko, <Kornel.Benko@berlin.de>
|
2008-12-28 13:35:29 +00:00
|
|
|
#
|
|
|
|
|
2009-01-06 18:51:00 +00:00
|
|
|
project(po)
|
2008-12-28 13:35:29 +00:00
|
|
|
|
|
|
|
include_directories(${TOP_SRC_DIR}/po)
|
|
|
|
|
2009-02-05 19:02:27 +00:00
|
|
|
SET(_lyxname ${PACKAGE})
|
2008-12-28 13:35:29 +00:00
|
|
|
SET(_py_sources)
|
|
|
|
macro(add_gettext_python _par _dir)
|
2009-04-05 16:02:46 +00:00
|
|
|
set(_sources)
|
|
|
|
foreach(_arg ${ARGN})
|
|
|
|
file(GLOB _s1 ${TOP_SRC_DIR}/${_dir}/${_arg})
|
2010-07-09 06:07:46 +00:00
|
|
|
list(SORT _s1)
|
2009-04-05 16:02:46 +00:00
|
|
|
list(APPEND _sources ${_s1})
|
|
|
|
endforeach(_arg)
|
2008-12-28 13:35:29 +00:00
|
|
|
SET(_dst "${CMAKE_CURRENT_BINARY_DIR}/${_par}_l10n.pot")
|
2009-05-12 09:21:59 +00:00
|
|
|
SET(_tmp_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_tmp_files")
|
|
|
|
SET(_src_files "${CMAKE_CURRENT_BINARY_DIR}/${_par}_files")
|
|
|
|
file(WRITE ${_tmp_src_files} "")
|
|
|
|
foreach(_s ${_sources})
|
|
|
|
FILE(APPEND ${_tmp_src_files} "${_s}\n")
|
|
|
|
endforeach()
|
2009-05-03 17:59:01 +00:00
|
|
|
if(${_par} MATCHES "^\(.*\)_[0-9]+$")
|
|
|
|
set(_par1 ${CMAKE_MATCH_1})
|
|
|
|
else()
|
|
|
|
set(_par1 ${_par})
|
|
|
|
endif()
|
2009-05-12 09:21:59 +00:00
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT ${_src_files}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_tmp_src_files} ${_src_files}
|
|
|
|
DEPENDS ${_tmp_src_files}
|
|
|
|
)
|
2008-12-28 13:35:29 +00:00
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
OUTPUT "${_dst}"
|
|
|
|
PRE_BUILD
|
|
|
|
COMMAND python
|
2009-05-12 09:21:59 +00:00
|
|
|
ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
|
|
|
|
DEPENDS ${_sources} ${_src_files}
|
2008-12-28 13:35:29 +00:00
|
|
|
)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES("${_dst}" GENERATED)
|
2009-05-12 09:21:59 +00:00
|
|
|
SET_SOURCE_FILES_PROPERTIES("${_src_files}" GENERATED)
|
2008-12-28 13:35:29 +00:00
|
|
|
LIST(APPEND _py_sources "${_dst}")
|
|
|
|
endmacro(add_gettext_python)
|
|
|
|
|
2009-02-05 19:02:27 +00:00
|
|
|
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot" GENERATED)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" GENERATED)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot" GENERATED)
|
2008-12-28 13:35:29 +00:00
|
|
|
|
2009-04-05 16:02:46 +00:00
|
|
|
add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
|
2009-05-12 09:21:59 +00:00
|
|
|
add_gettext_python(layouts lib/layouts *.layout *.inc *.module)
|
2009-04-05 16:02:46 +00:00
|
|
|
add_gettext_python(languages lib languages)
|
2008-12-28 13:35:29 +00:00
|
|
|
add_gettext_python(encodings lib encodings)
|
2009-05-12 09:21:59 +00:00
|
|
|
add_gettext_python(ui lib/ui *.ui *.inc)
|
2008-12-28 13:35:29 +00:00
|
|
|
add_gettext_python(external lib external_templates)
|
|
|
|
add_gettext_python(formats lib configure.py)
|
|
|
|
|
|
|
|
FIND_PROGRAM(GETTEXT_XGETTEXT_EXECUTABLE xgettext)
|
|
|
|
FIND_PROGRAM(GETTEXT_MSGUNIQ_EXECUTABLE msguniq)
|
|
|
|
|
|
|
|
# TODO:
|
|
|
|
# We need here perl, because I don't know how
|
|
|
|
# to write the alternative for "cat" in python
|
|
|
|
# e.g. perl -e "\"while(<>){print;}\""
|
|
|
|
# But maybe Jose knows?
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2009-02-05 19:02:27 +00:00
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
|
2009-04-15 07:28:37 +00:00
|
|
|
COMMAND ${_PERL_EXECUTABLE}
|
2009-02-05 19:02:27 +00:00
|
|
|
ARGS -e "\"while(<>){print;}\"" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
|
2008-12-28 13:35:29 +00:00
|
|
|
DEPENDS ${_py_sources}
|
|
|
|
)
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2009-02-05 19:02:27 +00:00
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
|
2008-12-28 13:35:29 +00:00
|
|
|
COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
|
2009-02-05 19:02:27 +00:00
|
|
|
ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
|
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
|
2008-12-28 13:35:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(_potfiles_dep)
|
2009-02-05 19:02:27 +00:00
|
|
|
|
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
|
2010-07-09 06:07:46 +00:00
|
|
|
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)
|
|
|
|
list(SORT _tmp_potfiles)
|
|
|
|
list(REMOVE_ITEM _tmp_potfiles src/support/Package.cpp)
|
|
|
|
|
|
|
|
foreach(_f ${_tmp_potfiles})
|
|
|
|
# we don't need to select only relevant files because the outcome of xgettext
|
|
|
|
# will stay the same.
|
|
|
|
# Relevant files are files containing the string '_(".*")'
|
|
|
|
LIST(APPEND _potfiles_dep "${TOP_SRC_DIR}/${_f}")
|
|
|
|
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "${_f}\n")
|
|
|
|
endforeach(_f)
|
2008-12-28 13:35:29 +00:00
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
2009-02-05 19:02:27 +00:00
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
|
2008-12-28 13:35:29 +00:00
|
|
|
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
|
2009-05-03 15:14:14 +00:00
|
|
|
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"
|
2009-02-05 19:02:27 +00:00
|
|
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
|
2008-12-28 13:35:29 +00:00
|
|
|
)
|
|
|
|
|
2009-03-25 06:49:49 +00:00
|
|
|
#
|
|
|
|
# We have to copy the po-files first,
|
|
|
|
# otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
|
|
|
|
# This makes the "svn up" on po-files work again
|
|
|
|
file(GLOB LYX_BASE_PO_FILES RELATIVE ${TOP_SRC_DIR}/po ${TOP_SRC_DIR}/po/*.po)
|
|
|
|
set(LYX_PO_FILES)
|
|
|
|
foreach(_pofile ${LYX_BASE_PO_FILES})
|
2009-04-15 07:14:29 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${TOP_SRC_DIR}/po/${_pofile} ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
|
|
|
|
DEPENDS ${TOP_SRC_DIR}/po/${_pofile}
|
|
|
|
)
|
2009-03-25 06:49:49 +00:00
|
|
|
list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
|
|
|
|
endforeach(_pofile)
|
2008-12-28 13:35:29 +00:00
|
|
|
|
2009-02-05 19:02:27 +00:00
|
|
|
GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ALL ${LYX_PO_FILES})
|
2008-12-28 13:35:29 +00:00
|
|
|
|
|
|
|
# ADD_POFILES("lyx")
|
|
|
|
|