2018-05-03 16:18:15 -05:00
add_subdirectory ( glossary )
2015-12-07 11:17:08 -06:00
2018-10-17 00:33:38 -05:00
# Set of available languages:
# * managed at the Translation Project (TP):
2019-04-16 13:06:02 -05:00
set ( TP_LINGUAS az ca cs da eu fa ja nl ro rw sk sr sv tr uk zh_CN )
2018-10-17 00:33:38 -05:00
# * already marked as external at TP:
2019-04-16 13:06:02 -05: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 ru ta te ur vi zh_TW )
2018-10-17 00:33:38 -05:00
# * New or unmarked: The release manager should announce them to TP
# and when listed there move in the respective group above.
2019-02-20 17:59:22 -06:00
set ( NEW_LINGUAS as brx doi es_NI hr kok kok@latin ks mai mni mni@bengali )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
set ( ALL_LINGUAS ${ TP_LINGUAS } ${ GC_LINGUAS } ${ NEW_LINGUAS } )
2015-12-07 11:17:08 -06:00
2018-02-27 08:45:38 -06:00
file ( WRITE LINGUAS "${ALL_LINGUAS}" )
2018-05-03 16:18:15 -05:00
set ( CATALOGS "" )
set ( BUILD_CATALOGS "" )
2016-01-13 10:45:29 -06:00
2018-05-03 16:18:15 -05:00
set ( po_SOURCES "" )
2018-02-27 08:45:38 -06:00
file ( WRITE LINGUAS "" )
2018-05-03 16:18:15 -05:00
foreach ( lingua ${ ALL_LINGUAS } )
list ( APPEND po_SOURCES ${ lingua } .po )
2018-02-27 08:45:38 -06:00
file ( APPEND LINGUAS "${lingua} " )
2018-05-03 16:18:15 -05:00
endforeach ( )
2017-02-01 21:48:46 -06:00
2019-04-25 22:35:39 -05:00
set_local_dist ( po_DIST_local ${ po_SOURCES } CMakeLists.txt Makevars
2018-02-28 06:40:15 -06:00
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 g n u c a s h - p o t . c m a k e )
2018-05-03 16:18:15 -05:00
set ( po_DIST ${ po_DIST_local } ${ po_glossary_DIST } PARENT_SCOPE )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
foreach ( lingua ${ ALL_LINGUAS } )
set ( _OUTPUT_FILE ${ lingua } .mo )
list ( APPEND CATALOGS ${ _OUTPUT_FILE } )
add_custom_command (
2015-12-07 11:17:08 -06:00
O U T P U T $ { _ O U T P U T _ F I L E }
2019-05-25 04:20:21 -05:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E e n v
2018-02-27 15:21:00 -06:00
$ { G E T T E X T _ M S G F M T _ E X E C U T A B L E }
- 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
2019-05-27 07:47:35 -05:00
D E P E N D S $ { 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
)
2018-05-03 16:18:15 -05:00
set ( _BUILD_FILE_DIR ${ DATADIR_BUILD } /locale/ ${ lingua } /LC_MESSAGES )
make_directory ( ${ _BUILD_FILE_DIR } )
set ( _BUILD_FILE ${ _BUILD_FILE_DIR } /gnucash.mo )
list ( APPEND BUILD_CATALOGS ${ _BUILD_FILE } )
add_custom_command (
2017-02-01 21:48:46 -06:00
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
)
2018-05-03 16:18:15 -05:00
endforeach ( lingua )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
add_custom_target ( po-gmo ALL DEPENDS ${ CATALOGS } )
add_custom_target ( po-gmo-build ALL DEPENDS ${ BUILD_CATALOGS } )
2015-12-07 11:17:08 -06:00
2018-05-03 16:18:15 -05:00
foreach ( lingua ${ ALL_LINGUAS } )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ lingua } .mo RENAME gnucash.mo DESTINATION ${ CMAKE_INSTALL_DATADIR } /locale/ ${ lingua } /LC_MESSAGES )
endforeach ( lingua )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05: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 ( )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
function ( make_gnucash_potfiles )
2017-02-01 21:48:46 -06:00
# Create a list of candidate translation files
2018-02-28 06:40:15 -06:00
file ( GLOB_RECURSE FILES_IN RELATIVE ${ CMAKE_SOURCE_DIR }
$ { 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 . i n
2019-08-26 11:57:45 -05:00
$ { 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 $ { C M A K E _ S O U R C E _ D I R } / * . a p p d a t a . x m l . i n . i n
2018-02-28 06:40:15 -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 } / * . s c m
$ { C M A K E _ S O U R C E _ D I R } / * / q o f b o o k s l o t s . h
2019-12-29 15:25:14 -06:00
$ { C M A K E _ S O U R C E _ D I R } / * / g n c - c o m m o d i t y . h
2018-02-28 06:40:15 -06:00
)
2017-02-01 21:48:46 -06:00
2018-02-28 06:40:15 -06:00
# Only consider files in a selection of the source directories and
# additionally check against list of ignore patterns
set ( GOOD_FILES "" )
foreach ( path ${ FILES_IN } )
if ( ${ path } MATCHES "^(bindings/|borrowed/|common/|doc/|libgnucash/|gnucash/)"
A N D
2018-11-04 06:07:36 -06:00
N O T $ { p a t h } M A T C H E S " g w - | t e s t | e x p e r i m e n t a l | p y t h o n - b i n d i n g s | s w i g - . * \ \ . c "
# Skip POSIX style hidden files even if they have the proper extension
# These are typically temporary files from editors like emacs
A N D
N O T $ { p a t h } M A T C H E S " / [ . ] [ ^ / ] * $ " )
2018-02-28 06:40:15 -06:00
list ( APPEND GOOD_FILES ${ path } )
2020-02-06 09:16:31 -06:00
endif ( )
2018-02-28 06:40:15 -06:00
endforeach ( path )
# Remove the paths that we have marked as explicitly skipped
2018-05-03 16:18:15 -05:00
read_file_removing_comments ( SKIP_LINES POTFILES.skip )
2018-02-28 06:40:15 -06:00
foreach ( path ${ SKIP_LINES } )
list ( REMOVE_ITEM GOOD_FILES ${ path } )
endforeach ( )
2017-02-01 21:48:46 -06:00
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.
2018-05-03 16:18:15 -05:00
string ( REPLACE ";" "\n" SORT_IN "${GOOD_FILES}" )
set ( SORT_IN "${SORT_IN}\n" )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /POTFILES.in.in "${SORT_IN}" )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -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
)
2018-05-03 16:18:15 -05:00
string ( REPLACE "\n" ";" POTFILES "${POTFILES_IN}" )
2017-02-01 21:48:46 -06:00
# Write out the final list.
# intltool-update insists that this file be in the source directory. :-(
2018-05-03 16:18:15 -05:00
set ( POTFILES_IN_PATH ${ CMAKE_CURRENT_BINARY_DIR } /POTFILES.in )
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 "" )
2018-05-03 16:18:15 -05:00
foreach ( path ${ POTFILES } )
2018-01-29 14:51:38 -06:00
list ( APPEND POTFILE_DEPS ${ CMAKE_SOURCE_DIR } / ${ path } )
2018-05-03 16:18:15 -05:00
file ( APPEND ${ POTFILES_IN_PATH } "${path}\n" )
endforeach ( )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -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" )
2018-05-03 16:18:15 -05:00
endfunction ( )
2017-02-01 21:48:46 -06:00
2020-02-07 14:56:21 -06:00
if ( BUILD_GNUCASH_POT )
2017-02-01 21:48:46 -06:00
2018-05-03 16:18:15 -05:00
make_gnucash_potfiles ( )
2017-02-01 21:48:46 -06:00
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
2018-05-03 16:18:15 -05:00
if ( ${ XGETTEXT } STREQUAL "XGETTEXT-NOTFOUND" )
message ( FATAL_ERROR "Can't find the 'xgettext' program." )
2020-02-06 09:16:31 -06:00
endif ( )
2017-02-01 21:48:46 -06:00
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 }
2018-02-27 08:45:38 -06:00
- D T O P _ S R C _ D I R = $ { C M A K E _ S O U R C E _ D I R }
2018-01-27 12:00:30 -06:00
- 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 }
2020-01-17 09:28:56 -06:00
- D P R O J E C T _ N A M E = $ { P R O J E C T _ N A M E }
2018-03-01 11:31:49 -06:00
- D P A C K A G E _ N A M E = $ { P A C K A G E _ N A M E }
2020-01-17 09:28:56 -06:00
- D P R O J E C T _ V E R S I O N = $ { P R O J E C T _ V E R S I O N }
2018-01-27 12:00:30 -06:00
- 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 )
2018-05-03 16:18:15 -05:00
endif ( )
2018-01-31 09:16:59 -06:00
dist_add_generated ( ${ BUILDING_FROM_VCS } gnucash.pot )