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
This commit is contained in:
Kornel Benko 2013-06-02 11:38:27 +02:00
parent c3796d8b88
commit 22d52f5f08
4 changed files with 34 additions and 10 deletions

View File

@ -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)

2
po/.gitignore vendored
View File

@ -1,7 +1,7 @@
POTFILES
POTFILES.in
lyx*.pot
*.gmo
#*.gmo
stamp-po
remove-potcdate.sed

View File

@ -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)

View File

@ -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");