Integrate the i18n CMake into the main CMake
This adds a new target i18n that will compile all the translation files.
This commit is contained in:
parent
e89316b0d5
commit
e9fa9f68b2
|
@ -98,6 +98,14 @@ option( KICAD_SPICE
|
||||||
"Build KiCad with internal Spice simulator."
|
"Build KiCad with internal Spice simulator."
|
||||||
ON )
|
ON )
|
||||||
|
|
||||||
|
option( KICAD_BUILD_I18N
|
||||||
|
"Buid the translations."
|
||||||
|
ON )
|
||||||
|
|
||||||
|
option( KICAD_I18N_UNIX_STRICT_PATH
|
||||||
|
"Use standard Unix locale lookup path (default OFF)."
|
||||||
|
OFF )
|
||||||
|
|
||||||
# Not supported by all platforms (for instance mingw)
|
# Not supported by all platforms (for instance mingw)
|
||||||
option( KICAD_SANITIZE
|
option( KICAD_SANITIZE
|
||||||
"Build KiCad with sanitizer options. WARNING: Not compatible with gold linker"
|
"Build KiCad with sanitizer options. WARNING: Not compatible with gold linker"
|
||||||
|
@ -614,6 +622,10 @@ include( ExternalProject )
|
||||||
#================================================
|
#================================================
|
||||||
include( CheckFindPackageResult )
|
include( CheckFindPackageResult )
|
||||||
|
|
||||||
|
if( KICAD_BUILD_I18N )
|
||||||
|
find_package( Gettext REQUIRED )
|
||||||
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find OpenGL library, required
|
# Find OpenGL library, required
|
||||||
#
|
#
|
||||||
|
@ -1071,4 +1083,10 @@ add_subdirectory( qa )
|
||||||
if( KICAD_INSTALL_DEMOS )
|
if( KICAD_INSTALL_DEMOS )
|
||||||
add_subdirectory( demos )
|
add_subdirectory( demos )
|
||||||
endif ( KICAD_INSTALL_DEMOS )
|
endif ( KICAD_INSTALL_DEMOS )
|
||||||
|
|
||||||
|
# I18n Translations
|
||||||
|
if( KICAD_BUILD_I18N )
|
||||||
|
add_subdirectory( translation )
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory( template )
|
add_subdirectory( template )
|
||||||
|
|
|
@ -116,3 +116,36 @@ macro( add_conffiles )
|
||||||
set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/conffiles )
|
set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/conffiles )
|
||||||
endif()
|
endif()
|
||||||
endmacro( add_conffiles )
|
endmacro( add_conffiles )
|
||||||
|
|
||||||
|
|
||||||
|
# Function translate_language
|
||||||
|
#
|
||||||
|
# This is a function to add the targets and install step for translating a language
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - LANG is the code for the language (which must be the same as the directory name)
|
||||||
|
# - OUT_FILE is the file (including directory) to save the translations to
|
||||||
|
function( translate_language LANG OUT_FILE)
|
||||||
|
# Make the output directory (if it doesn't already exist)
|
||||||
|
get_filename_component( OUT_DIR ${OUT_FILE} DIRECTORY )
|
||||||
|
|
||||||
|
file( MAKE_DIRECTORY ${OUT_DIR} )
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${OUT_FILE}
|
||||||
|
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${LANG}/kicad.po
|
||||||
|
-o ${OUT_FILE}
|
||||||
|
COMMENT "Building translation library for ${LANG}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH )
|
||||||
|
install( FILES ${OUT_FILE}
|
||||||
|
DESTINATION ${KICAD_I18N_PATH}/${LANG}/LC_MESSAGES
|
||||||
|
COMPONENT resources )
|
||||||
|
else()
|
||||||
|
install( FILES ${OUT_FILE}
|
||||||
|
DESTINATION ${KICAD_I18N_PATH}/${LANG}
|
||||||
|
COMPONENT resources )
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
|
@ -1,21 +1,3 @@
|
||||||
cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
|
|
||||||
|
|
||||||
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
|
|
||||||
message( FATAL_ERROR
|
|
||||||
"In-source builds not allowed. Please make a new directory (called"
|
|
||||||
" a build directory) and run CMake from there, points here."
|
|
||||||
" You may need to remove CMakeCache.txt." )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
project( kicad-i18n NONE )
|
|
||||||
|
|
||||||
find_package( Gettext REQUIRED )
|
|
||||||
|
|
||||||
option( KICAD_I18N_UNIX_STRICT_PATH
|
|
||||||
"Use standard Unix locale lookup path (default OFF)."
|
|
||||||
OFF
|
|
||||||
)
|
|
||||||
|
|
||||||
if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH )
|
if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH )
|
||||||
set( KICAD_I18N_PATH ${CMAKE_INSTALL_PREFIX}/share/locale
|
set( KICAD_I18N_PATH ${CMAKE_INSTALL_PREFIX}/share/locale
|
||||||
CACHE PATH "Location of KiCad i18n files." )
|
CACHE PATH "Location of KiCad i18n files." )
|
||||||
|
@ -27,21 +9,16 @@ endif()
|
||||||
|
|
||||||
file(STRINGS LINGUAS LANG_ARRAY REGEX "^[^#].*")
|
file(STRINGS LINGUAS LANG_ARRAY REGEX "^[^#].*")
|
||||||
|
|
||||||
|
# Add the commands to translate each language file
|
||||||
foreach( LANG ${LANG_ARRAY} )
|
foreach( LANG ${LANG_ARRAY} )
|
||||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${LANG})
|
set( OUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${LANG}/kicad.mo" )
|
||||||
|
|
||||||
execute_process( COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
|
translate_language( ${LANG} ${OUT_FILE} )
|
||||||
${CMAKE_SOURCE_DIR}/${LANG}/kicad.po
|
|
||||||
-o ${CMAKE_BINARY_DIR}/${LANG}/kicad.mo )
|
|
||||||
|
|
||||||
if( UNIX AND KICAD_I18N_UNIX_STRICT_PATH )
|
# Keep a list of the language files that are created to add to the target
|
||||||
install( FILES ${CMAKE_BINARY_DIR}/${LANG}/kicad.mo
|
list( APPEND LANG_FILES "${OUT_FILE}" )
|
||||||
DESTINATION ${KICAD_I18N_PATH}/${LANG}/LC_MESSAGES
|
|
||||||
COMPONENT resources )
|
|
||||||
else()
|
|
||||||
install( FILES ${CMAKE_BINARY_DIR}/${LANG}/kicad.mo
|
|
||||||
DESTINATION ${KICAD_I18N_PATH}/${LANG}
|
|
||||||
COMPONENT resources )
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# Add the target that executes the translation commands
|
||||||
|
add_custom_target( i18n ALL
|
||||||
|
DEPENDS ${LANG_FILES} )
|
||||||
|
|
Loading…
Reference in New Issue