2017-02-01 21:48:46 -06:00
ADD_SUBDIRECTORY ( glossary )
2015-12-07 11:17:08 -06:00
# Set of available languages.
2016-01-20 10:46:01 -06:00
SET ( TP_LINGUAS az ca cs da eu fa ja nl rw sk sr sv tr uk zh_CN )
2015-12-07 11:17:08 -06:00
# already marked as external at TP:
2016-01-20 10:46:01 -06:00
SET ( GC_LINGUAS ar bg de el en_GB es fi fr gu he hi hu it kn ko lt lv mr nb ne pl pt pt_BR ro ru ta te ur vi zh_TW )
2015-12-07 11:17:08 -06:00
# not marked or no TP team:
SET ( NEW_LINGUAS as brx doi es_NI kok kok@latin ks mai mni mni@bengali )
SET ( ALL_LINGUAS ${ TP_LINGUAS } ${ GC_LINGUAS } ${ NEW_LINGUAS } )
SET ( CATALOGS "" )
SET ( BUILD_CATALOGS "" )
2016-01-13 10:45:29 -06:00
SET ( CMAKE_COMMAND_TMP "" )
IF ( ${ CMAKE_VERSION } VERSION_GREATER 3.1 )
SET ( CMAKE_COMMAND_TMP ${ CMAKE_COMMAND } -E env )
ENDIF ( )
2017-02-01 21:48:46 -06:00
SET ( po_SOURCES "" )
FOREACH ( lingua ${ ALL_LINGUAS } )
LIST ( APPEND po_SOURCES ${ lingua } .po )
ENDFOREACH ( )
2017-07-04 20:36:35 -05:00
SET_LOCAL_DIST ( po_DIST_local ${ po_SOURCES } CMakeLists.txt ChangeLog Makevars
2018-01-27 12:00:30 -06:00
P O T F I L E S . i g n o r e P O T F I L E S . i n P O T F I L E S . s k i p R E A D M E c h e c k - p o . c m a k e g n u c a s h - p o t . c m a k e )
2017-02-01 21:48:46 -06:00
SET ( po_DIST ${ po_DIST_local } ${ po_glossary_DIST } PARENT_SCOPE )
2015-12-07 11:17:08 -06:00
FOREACH ( lingua ${ ALL_LINGUAS } )
2017-09-08 11:54:17 -05:00
SET ( _OUTPUT_FILE ${ lingua } .mo )
2015-12-07 11:17:08 -06:00
LIST ( APPEND CATALOGS ${ _OUTPUT_FILE } )
ADD_CUSTOM_COMMAND (
O U T P U T $ { _ O U T P U T _ F I L E }
2016-01-13 10:45:29 -06:00
C O M M A N D $ { C M A K E _ C O M M A N D _ T M P } $ { M S G F M T } - o $ { _ O U T P U T _ F I L E } $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { l i n g u a } . p o
2015-12-07 11:17:08 -06:00
)
2017-10-04 16:01:03 -05:00
SET ( _BUILD_FILE_DIR ${ DATADIR_BUILD } /locale/ ${ lingua } /LC_MESSAGES )
2017-02-01 21:48:46 -06:00
MAKE_DIRECTORY ( ${ _BUILD_FILE_DIR } )
2017-09-08 11:54:17 -05:00
SET ( _BUILD_FILE ${ _BUILD_FILE_DIR } /gnucash.mo )
2017-02-01 21:48:46 -06:00
LIST ( APPEND BUILD_CATALOGS ${ _BUILD_FILE } )
ADD_CUSTOM_COMMAND (
O U T P U T $ { _ B U I L D _ F I L E }
2017-09-08 11:54:17 -05:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { l i n g u a } . m o $ { _ B U I L D _ F I L E }
2017-02-01 21:48:46 -06:00
D E P E N D S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { _ O U T P U T _ F I L E }
#APPEND
2015-12-07 11:17:08 -06:00
)
ENDFOREACH ( lingua )
ADD_CUSTOM_TARGET ( po-gmo ALL DEPENDS ${ CATALOGS } )
2017-02-01 21:48:46 -06:00
ADD_CUSTOM_TARGET ( po-gmo-build ALL DEPENDS ${ BUILD_CATALOGS } )
2015-12-07 11:17:08 -06:00
FOREACH ( lingua ${ ALL_LINGUAS } )
2017-11-30 15:56:47 -06:00
INSTALL ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ lingua } .mo RENAME gnucash.mo DESTINATION ${ CMAKE_INSTALL_DATADIR } /locale/ ${ lingua } /LC_MESSAGES )
2016-01-20 10:46:01 -06:00
ENDFOREACH ( lingua )
2017-02-01 21:48:46 -06:00
FUNCTION ( READ_FILE_REMOVING_COMMENTS OUTPUT PATH )
SET ( RESULT "" )
FILE ( STRINGS "${PATH}" LINES_IN )
FOREACH ( line ${ LINES_IN } )
STRING ( REGEX REPLACE "#.*" "" line2 ${ line } )
LIST ( APPEND RESULT ${ line2 } )
ENDFOREACH ( )
SET ( ${ OUTPUT } ${ RESULT } PARENT_SCOPE )
ENDFUNCTION ( )
FUNCTION ( MAKE_GNUCASH_POTFILES )
2017-08-09 09:09:32 -05:00
SET ( IGNORE_PATTERNS "gw-" "test" "experimental" "python-bindings" "swig-.*\\.c" )
2017-07-04 20:36:35 -05:00
2017-02-01 21:48:46 -06:00
# Create a list of candidate translation files
FILE ( GLOB_RECURSE FILES_IN RELATIVE ${ CMAKE_SOURCE_DIR }
2017-07-04 20:36:35 -05:00
$ { C M A K E _ S O U R C E _ D I R } / * . c $ { C M A K E _ S O U R C E _ D I R } / * . c p p $ { C M A K E _ S O U R C E _ D I R } / * . g l a d e $ { C M A K E _ S O U R C E _ D I R } / * . d e s k t o p . i n
2017-02-01 21:48:46 -06:00
$ { C M A K E _ S O U R C E _ D I R } / * . k e y s . i n $ { C M A K E _ S O U R C E _ D I R } / * . g s c h e m a . x m l . i n . i n $ { C M A K E _ S O U R C E _ D I R } / * . s c m )
2017-08-10 06:56:00 -05:00
# Only consider files in the common, libgnucash, and gnucash/ directories. Also check against list of ignore patterns
2017-02-01 21:48:46 -06:00
SET ( FILES "" )
FOREACH ( path ${ FILES_IN } )
2017-08-17 08:25:41 -05:00
STRING ( REGEX MATCH "^(bindings/|common/|borrowed/|libgnucash/|gnucash/)" IS_SRC ${ path } )
2017-02-01 21:48:46 -06:00
IF ( IS_SRC )
SET ( IS_IGNORED FALSE )
FOREACH ( pattern ${ IGNORE_PATTERNS } )
STRING ( REGEX MATCH ${ pattern } YES_IGNORE ${ path } )
IF ( YES_IGNORE )
SET ( IS_IGNORED TRUE )
ENDIF ( )
ENDFOREACH ( pattern )
IF ( NOT IS_IGNORED )
LIST ( APPEND FILES ${ path } )
ENDIF ( NOT IS_IGNORED )
2017-07-04 20:36:35 -05:00
ENDIF ( IS_SRC )
2017-02-01 21:48:46 -06:00
ENDFOREACH ( path )
# Read in list of paths to skip from POTFILES.{skip,ignore}
READ_FILE_REMOVING_COMMENTS ( SKIP_LINES POTFILES.skip )
READ_FILE_REMOVING_COMMENTS ( IGNORE_LINES POTFILES.ignore )
# Remove the paths that are skipped or ignored
FOREACH ( path ${ SKIP_LINES } ${ IGNORE_LINES } )
list ( REMOVE_ITEM FILES ${ path } )
ENDFOREACH ( )
2017-07-04 20:36:35 -05:00
2018-01-26 09:06:29 -06:00
# CMake sorting is different from UNIX sorting. Use perl to
# sort POTFILES.in universally. This may no longer be needed
# now we have dropped autotools support.
2017-02-01 21:48:46 -06:00
STRING ( REPLACE ";" "\n" SORT_IN "${FILES}" )
2017-09-06 16:51:26 -05:00
SET ( SORT_IN "${SORT_IN}\n" )
2017-02-01 21:48:46 -06:00
FILE ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /POTFILES.in.in "${SORT_IN}" )
2017-08-03 05:02:49 -05:00
EXECUTE_PROCESS ( COMMAND "${PERL_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/util/elegant-sort.pl"
2017-02-01 21:48:46 -06:00
I N P U T _ F I L E $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / P O T F I L E S . i n . i n
O U T P U T _ V A R I A B L E P O T F I L E S _ I N
)
STRING ( REPLACE "\n" ";" POTFILES "${POTFILES_IN}" )
2018-01-29 14:51:38 -06:00
# These are manually added, because they're not picked up by the generation script
list ( APPEND POTFILES
" g n u c a s h / g n o m e / g n u c a s h . a p p d a t a . x m l . i n "
" g n u c a s h / g n o m e / g n u c a s h . d e s k t o p . i n . i n "
" l i b g n u c a s h / e n g i n e / q o f b o o k s l o t s . h "
" d o c / t i p _ o f _ t h e _ d a y . l i s t . i n " )
2017-02-01 21:48:46 -06:00
# Write out the final list.
# intltool-update insists that this file be in the source directory. :-(
2017-09-12 16:13:23 -05:00
SET ( POTFILES_IN_PATH ${ CMAKE_CURRENT_BINARY_DIR } /POTFILES.in )
2017-08-03 05:02:49 -05:00
FILE ( WRITE ${ POTFILES_IN_PATH } " # This is a list of files which contain translatable strings.
2018-01-26 09:06:29 -06:00
# This file was autogenerated by cmake.
2017-02-01 21:48:46 -06:00
" )
2018-01-29 14:51:38 -06:00
set ( POTFILE_DEPS "" )
2017-02-01 21:48:46 -06:00
FOREACH ( path ${ POTFILES } )
2018-01-29 14:51:38 -06:00
list ( APPEND POTFILE_DEPS ${ CMAKE_SOURCE_DIR } / ${ path } )
2017-02-01 21:48:46 -06:00
STRING ( REGEX MATCH gschema.xml.in.in IS_GSCHEMA ${ path } )
2017-09-12 16:13:23 -05:00
IF ( IS_GSCHEMA )
2017-02-01 21:48:46 -06:00
# Force parse type for gsettings files
SET ( path "[type: gettext/gsettings]${path}" )
ENDIF ( )
FILE ( APPEND ${ POTFILES_IN_PATH } "${path}\n" )
ENDFOREACH ( )
2017-09-12 16:13:23 -05:00
CONFIGURE_FILE ( ${ POTFILES_IN_PATH } ${ CMAKE_CURRENT_SOURCE_DIR } /POTFILES.in NEWLINE_STYLE LF )
2018-01-29 14:51:38 -06:00
set ( gnucash_pot_depends ${ POTFILE_DEPS } CACHE INTERNAL "List of files with translatable strings. If any of these change, gnucash.pot should be regenerated" )
2017-02-01 21:48:46 -06:00
ENDFUNCTION ( )
find_program ( INTLTOOL_UPDATE NAMES intltool-update )
IF ( ${ INTLTOOL_UPDATE } STREQUAL "INTLTOOL_UPDATE-NOTFOUND" )
MESSAGE ( FATAL_ERROR "Can't find the 'intltool-update' program." )
ENDIF ( )
IF ( BUILDING_FROM_VCS )
2017-09-12 16:13:23 -05:00
MAKE_GNUCASH_POTFILES ( )
2017-02-01 21:48:46 -06:00
find_program ( INTLTOOL_EXTRACT NAMES intltool-extract )
find_program ( XGETTEXT xgettext )
2018-02-19 17:48:28 -06:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /Makevars
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / M a k e v a r s C O P Y O N L Y )
2017-02-01 21:48:46 -06:00
IF ( ${ INTLTOOL_EXTRACT } STREQUAL "INTLTOOL_EXTRACT-NOTFOUND" )
MESSAGE ( FATAL_ERROR "Can't find the 'intltool-extract' program." )
ENDIF ( )
IF ( ${ XGETTEXT } STREQUAL "XGETTEXT-NOTFOUND" )
MESSAGE ( FATAL_ERROR "Can't find the 'xgettext' program." )
ENDIF ( )
2018-01-29 05:19:47 -06:00
add_custom_command ( OUTPUT gnucash.pot
2018-01-27 12:00:30 -06:00
C O M M A N D $ { C M A K E _ C O M M A N D }
- D I N T L T O O L _ E X T R A C T = $ { I N T L T O O L _ E X T R A C T }
- D I N T L T O O L _ U P D A T E = $ { I N T L T O O L _ U P D A T E }
- D P O _ S R C _ D I R = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
- D P O _ B I N _ D I R = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
- D P A C K A G E = $ { P A C K A G E }
- D P E R L = $ { P E R L _ E X E C U T A B L E }
- D X G E T T E X T = $ { X G E T T E X T }
- P $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / g n u c a s h - p o t . c m a k e
2018-01-29 14:51:38 -06:00
D E P E N D S $ { g n u c a s h _ p o t _ d e p e n d s }
2018-01-27 12:00:30 -06:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
)
2018-01-29 14:51:38 -06:00
add_custom_target ( pot DEPENDS gnucash.pot )
2017-02-01 21:48:46 -06:00
ENDIF ( )
2018-01-31 09:16:59 -06:00
dist_add_generated ( ${ BUILDING_FROM_VCS } gnucash.pot )
2017-02-01 21:48:46 -06:00
ADD_CUSTOM_TARGET ( check-po
C O M M A N D $ { C M A K E _ C O M M A N D }
- D I N T L T O O L _ U P D A T E = $ { I N T L T O O L _ U P D A T E }
- D P O _ D I R = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
- P c h e c k - p o . c m a k e
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2017-08-03 05:02:49 -05:00
)
2018-02-19 00:16:27 -06:00
add_dependencies ( check check-po )