#TODO:
# disable NLS on demand
# installation
# update-po
# rebuild *.po if vlc.pot has changed (include POTFILES.in)


#FIXME: detection ?
find_program( GMSGFMT            msgfmt )
find_program( MSGFMT             msgfmt )
find_program( XGETTEXT           xgettext )
find_program( MSGMERGE_UPDATE    msgmerge --update )
find_program( MSGINIT            msginit )
find_program( MSGCONV            msgconv )
find_program( MSGFILTER          msgfilter )

set( POFILES
    af
	ar
	bn
	ca
	co
	cs
	da
	de
	el
	en_GB
	es
	eu
	fa
	fi
	fr
	fur
	gl
	he
	hi
	hu
	it
	ja
	ka
	ko
	lt
	lv
	ms
	my
	ne
	nl
	no
	oc
	pa
	pl
	ps
	pt_BR
	pt_PT
	ro
	ru
	sk
	sl
	sq
	sv
	tet
	th
	tl
	tr
	zh_CN
	zh_TW
)

FOREACH( pofile ${POFILES} )
    set( po-target ${po-target} ${CMAKE_CURRENT_BINARY_DIR}/${pofile}.gmo )
ENDFOREACH( pofile)

ADD_CUSTOM_TARGET( all-po ALL
    DEPENDS ${po-target}
)

foreach( pofile ${POFILES} )
    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${pofile}.gmo
        COMMAND rm -f ${CMAKE_CURRENT_BINARY_DIR}/${pofile}.gmo
        COMMAND ${GMSGFMT} -c --statistics -o ${CMAKE_CURRENT_BINARY_DIR}/t-${pofile}.gmo ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}.po
        COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/t-${pofile}.gmo ${CMAKE_CURRENT_BINARY_DIR}/${pofile}.gmo
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}.po
    )
endforeach( pofile )
