SET(_lyxname ${PACKAGE})
SET(_py_sources)
+
macro(add_gettext_python _par _dir)
set(_sources)
foreach(_arg ${ARGN})
DEPENDS ${_tmp_src_files}
)
if (${_par} MATCHES "layouttranslations")
+ # lyx_pot.py requires the module "polib" if using target layouttranslations1,
+ # so we have to check for it
+ find_python_module("polib")
+ if ("${LYX_PY_POLIB}" STREQUAL "")
+ message(STATUS "You will be unable to update layouttranslations file")
+ endif()
ADD_CUSTOM_COMMAND(
OUTPUT "${_dst}"
PRE_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${TOP_SRC_DIR}/lib/layouttranslations" "${_dst}"
- COMMAND ${LYX_PYTHON_EXECUTABLE}
- ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dst}" "${TOP_SRC_DIR}/lib/layouttranslations"
- DEPENDS ${_sources} ${_src_files} "${TOP_SRC_DIR}/lib/layouttranslations"
+ COMMAND ${CMAKE_COMMAND}
+ "-DTOP_SRC_DIR=${TOP_SRC_DIR}"
+ "-DDestFile=${_dst}"
+ "-DLYX_PYTHON_EXECUTABLE=${LYX_PYTHON_EXECUTABLE}"
+ "-DParType=${_par1}"
+ "-DSources=${_src_files}"
+ "-DLYX_PY_POLIB=${LYX_PY_POLIB}"
+ -P "${TOP_SRC_DIR}/po/CreateLayoutTranslations.cmake"
+ DEPENDS ${_sources} ${_src_files} "${TOP_SRC_DIR}/lib/layouttranslations" "${TOP_SRC_DIR}/po/lyx_pot.py"
COMMENT "${LYX_PYTHON_EXECUTABLE} ${TOP_SRC_DIR}/po/lyx_pot.py -b ${TOP_SRC_DIR} -o ${_dst} -t ${_par1} --src_file=${_src_files}"
)
ADD_CUSTOM_TARGET(layouttranslations1 DEPENDS "${_dst}")
+ set_target_properties(layouttranslations1 PROPERTIES FOLDER "i18n")
if (LYX_DATA_SUBDIR STREQUAL "")
install(FILES "${TOP_SRC_DIR}/lib/layouttranslations" DESTINATION .)
else()
PRE_BUILD
COMMAND ${LYX_PYTHON_EXECUTABLE}
ARGS "${TOP_SRC_DIR}/po/lyx_pot.py" -b "${TOP_SRC_DIR}" -o "${_dst}" -t ${_par1} "--src_file=${_src_files}"
- DEPENDS ${_sources} ${_src_files}
+ DEPENDS ${_sources} ${_src_files} "${TOP_SRC_DIR}/po/lyx_pot.py"
COMMENT "${LYX_PYTHON_EXECUTABLE} ${TOP_SRC_DIR}/po/lyx_pot.py -b ${TOP_SRC_DIR} -o ${_dst} -t ${_par1} --src_file=${_src_files}"
)
LIST(APPEND _py_sources "${_dst}")
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)
+if (UNIX)
+ # create symbolic links for external lokalizations programs
+ # to be able to find the referenced sources if used on
+ # built po-files
+ foreach (_dir lib src)
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E create_symlink "${TOP_SRC_DIR}/${_dir}" "${CMAKE_CURRENT_BINARY_DIR}/${_dir}")
+ endforeach()
+endif()
-add_gettext_python(qt4 src/frontends/qt4/ui *.ui)
-add_gettext_python(layouts lib/layouts *.layout *.inc *.module)
+add_gettext_python(layouttranslations lib layouts/*.layout layouts/*.inc layouts/*.module citeengines/*.citeengine)
add_gettext_python(languages lib languages)
+add_gettext_python(layouts lib layouts/*.layout layouts/*.inc layouts/*.module citeengines/*.citeengine)
add_gettext_python(latexfonts lib latexfonts)
add_gettext_python(encodings lib encodings)
add_gettext_python(ui lib/ui *.ui *.inc)
-add_gettext_python(external lib external_templates)
+add_gettext_python(external lib/xtemplates *.xtemplate)
add_gettext_python(formats lib configure.py)
-add_gettext_python(layouttranslations lib/layouts *.layout *.inc *.module)
+add_gettext_python(tabletemplates lib tabletemplates/*.lyx)
+add_gettext_python(qt src/frontends/qt/ui *.ui)
+add_gettext_python(examples_templates lib examples/[a-zA-Z]* templates/[a-zA-Z]*)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
COMMAND ${LYX_PYTHON_EXECUTABLE}
- ARGS "${TOP_SRC_DIR}/development/cmake/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
- COMMAND ${LYX_PYTHON_EXECUTABLE}
- ARGS "${TOP_SRC_DIR}/development/cmake/po/dos2unix.py" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
+ ARGS "${TOP_CMAKE_PATH}/po/cat.py" ${_py_sources} > "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat_tmp.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
DEPENDS ${_py_sources}
)
ADD_CUSTOM_COMMAND(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
COMMAND ${GETTEXT_MSGUNIQ_EXECUTABLE}
- ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
+ ARGS -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt_tmp.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt_tmp.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.cat.pot"
)
SET(_potfiles_dep)
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in "")
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in.tmp "")
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)
# 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")
+ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in.tmp "${_f}\n")
endforeach(_f)
-ADD_CUSTOM_COMMAND(
- 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"
- COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
- --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"
- DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
- )
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in.tmp" "${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in"
+ )
+
+if (GETTEXT_MSGCAT_EXECUTABLE)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
+ COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
+ --from-code=UTF-8
+ --default-domain=${_lyxname} --directory=${TOP_SRC_DIR}
+ --add-comments=TRANSLATORS:
+ --language=C++ --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}.src.pot"
+ COMMAND ${GETTEXT_MSGCAT_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.src.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" -o "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
+ )
+
+else()
+ ADD_CUSTOM_COMMAND(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
+ COMMAND ${CMAKE_COMMAD} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot"
+ COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
+ --from-code=UTF-8
+ --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"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.fmt.pot" ${_potfiles_dep}
+ )
+endif()
#
# We have to copy the po-files first,
# otherwise they would be modified (inside the macro GETTEXT_CREATE_TRANSLATIONS())
string(REGEX REPLACE "^(.*)\\.po$" "\\1" _inst_lng ${_pofile})
list(FIND CONFIGURED_LANGUAGES ${_inst_lng} _lng_idx)
if(_lng_idx GREATER -1)
- list(APPEND INSTALLED_LANGUAGES "${_inst_lng} ")
+ list(APPEND INSTALLED_LANGUAGES ${_inst_lng})
endif()
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
endforeach(_pofile)
+FIND_PROGRAM(LYX_GITVERSION git)
+set(LYX_UPDATED_GMO_FILES)
+foreach(_gmo_base ${INSTALLED_LANGUAGES})
+ set(_gmo ${_gmo_base}.gmo)
+ set(_tobeupdated "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}.tobeupdated")
+ list(APPEND LYX_UPDATED_GMO_FILES "${_tobeupdated}")
+ if(LYX_GITVERSION)
+ add_custom_command(
+ OUTPUT "${_tobeupdated}"
+ COMMAND "${LYX_GITVERSION}" "status" "--porcelain" "${_gmo_base}.po" ">" "${_tobeupdated}"
+ COMMAND ${LYX_PYTHON_EXECUTABLE} "${TOP_CMAKE_PATH}/po/update-gmo.py"
+ "${_tobeupdated}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}"
+ "${LYX_DEST_PO}/${_gmo}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}"
+ )
+ else()
+ add_custom_command(
+ OUTPUT "${_tobeupdated}"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}" "${LYX_DEST_PO}/${_gmo}"
+ COMMAND ${CMAKE_COMMAND} -E touch "${_tobeupdated}"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}"
+ )
+ endif()
+endforeach()
+
set(LYX_UPDATED_PO_FILES)
foreach(_pofile ${LYX_BASE_PO_FILES})
if(WIN32)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}.copied
COMMAND ${LYX_PYTHON_EXECUTABLE}
- ARGS "${TOP_SRC_DIR}/development/cmake/po/unix2dos.py" "${CMAKE_CURRENT_BINARY_DIR}/${_pofile}"
+ ARGS "${TOP_CMAKE_PATH}/po/unix2dos.py" "${CMAKE_CURRENT_BINARY_DIR}/${_pofile}"
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${_pofile} ${LYX_DEST_PO}/${_pofile}
COMMAND ${CMAKE_COMMAND} -E touch ${_pofile}.copied
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_pofile}
# Create a new target to remerge po files
# ALL omitted here, to prevent from automatic creation
-ADD_CUSTOM_TARGET(update-po DEPENDS ${LYX_UPDATED_PO_FILES})
+ADD_CUSTOM_TARGET(update-gmo DEPENDS ${LYX_UPDATED_GMO_FILES})
+ADD_CUSTOM_TARGET(update-po DEPENDS ${LYX_UPDATED_PO_FILES} ${LYX_UPDATED_GMO_FILES})
+set_target_properties(update-po update-gmo PROPERTIES FOLDER "i18n")
add_dependencies(update-po translations)
+add_dependencies(update-gmo translations)
+add_dependencies(update-gmo update-po)