commit 22d52f5f08cba82c85019634420f4204da56ec6b
Author: Kornel Benko <[email protected]>
Date: Sun Jun 2 11:38:27 2013 +0200
cmake: Use provided gmo-files if platform lacks python or gettext tools.
Running lyx from the build-directory now searches for the gmo-files
first in the build dir and then in source dir
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa53dd0..d0fa522 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -510,11 +510,18 @@ endif()
if(LYX_NLS)
FIND_PROGRAM(LYX_PYTHON_EXECUTABLE python2 python HINTS
${GNUWIN32_DIR}/python)
- if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
- message(FATAL_ERROR "Python 2.6 needed!")
+ find_package(LyXGettext)
+ if(LYX_PYTHON_EXECUTABLE AND GETTEXT_FOUND)
+ add_subdirectory(po "${TOP_BINARY_DIR}/po")
+ else()
+ # Install only supplied .gmo-files
+ file(GLOB _gmofiles RELATIVE "${TOP_SRC_DIR}/po"
"${TOP_SRC_DIR}/po/*.gmo")
+ message(STATUS "Installing provided .gmo-files only")
+ foreach( _gmo ${_gmofiles})
+ string(REGEX REPLACE "\\.gmo$" "" _lang ${_gmo})
+ install(FILES "${TOP_SRC_DIR}/po/${_gmo}" DESTINATION
${LYX_DATA_SUBDIR}${LYX_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${PACKAGE}.mo)
+ endforeach()
endif()
- find_package(LyXGettext REQUIRED)
- add_subdirectory(po "${TOP_BINARY_DIR}/po")
endif()
find_package(ICONV REQUIRED)
diff --git a/po/.gitignore b/po/.gitignore
index 63195a1..46f285c 100644
--- a/po/.gitignore
+++ b/po/.gitignore
@@ -1,7 +1,7 @@
POTFILES
POTFILES.in
lyx*.pot
-*.gmo
+#*.gmo
stamp-po
remove-potcdate.sed
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index d02c406..cdce457 100755
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -155,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}
@@ -165,6 +165,17 @@ foreach(_pofile ${LYX_BASE_PO_FILES})
list(APPEND LYX_PO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${_pofile})
endforeach(_pofile)
+set(LYX_UPDATED_GMO_FILES)
+foreach(_gmo_base ${INSTALLED_LANGUAGES})
+ set(_gmo ${_gmo_base}.gmo)
+ add_custom_command(
+ OUTPUT "${LYX_DEST_PO}/${_gmo}"
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_CURRENT_BINARY_DIR}/${_gmo}" "${LYX_DEST_PO}/${_gmo}"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_gmo}"
+ )
+ list(APPEND LYX_UPDATED_GMO_FILES "${LYX_DEST_PO}/${_gmo}")
+endforeach()
+
set(LYX_UPDATED_PO_FILES)
foreach(_pofile ${LYX_BASE_PO_FILES})
if(WIN32)
@@ -194,7 +205,7 @@
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-po DEPENDS ${LYX_UPDATED_PO_FILES}
${LYX_UPDATED_GMO_FILES})
set_target_properties(update-po PROPERTIES FOLDER "i18n")
add_dependencies(update-po translations)
diff --git a/src/support/Package.cpp b/src/support/Package.cpp
index 59972d2..2e2aebd 100644
--- a/src/support/Package.cpp
+++ b/src/support/Package.cpp
@@ -168,9 +168,15 @@ void Package::set_temp_dir(FileName const & temp_dir) const
FileName Package::messages_file(string const & c) const
{
- if (in_build_dir_)
- return FileName(top_srcdir().absFileName() + "/po/"
- + c + ".gmo");
+ if (in_build_dir_) {
+ FileName res = FileName(lyx_dir().absFileName() + "/po/"
+ + c + ".gmo");
+ if (!res.isReadableFile())
+ res = FileName(top_srcdir().absFileName() + "/po/"
+ + c + ".gmo");
+
+ return res;
+ }
else
return FileName(locale_dir_.absFileName() + "/" + c
+ "/LC_MESSAGES/" PACKAGE ".mo");