]> git.lyx.org Git - lyx.git/blobdiff - po/CMakeLists.txt
Add Mingyi Wu to contributors
[lyx.git] / po / CMakeLists.txt
index 9dd941eae6eebdf8249b8e8b36ebf454dfcc29c1..676ecdef9db336fd9e2afdf2f9bb33507c91f77e 100755 (executable)
@@ -51,6 +51,7 @@ macro(add_gettext_python  _par _dir)
       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()
@@ -154,7 +155,7 @@ foreach(_pofile ${LYX_BASE_PO_FILES})
   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}
@@ -164,6 +165,33 @@ foreach(_pofile ${LYX_BASE_PO_FILES})
   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)
@@ -193,6 +221,8 @@ GETTEXT_CREATE_TRANSLATIONS(${CMAKE_CURRENT_BINARY_DIR}/${_lyxname}.pot ${_addAL
 
 # 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)