1 # List here all source files with translatable strings.
2 POTFILES=$(sort $(shell find ../IkiWiki -type f -name \*.pm)) \
3 ../ikiwiki.in ../IkiWiki.pm ../auto.setup
5 POFILES=$(wildcard *.po)
6 MOFILES=$(POFILES:.po=.mo)
8 all: ikiwiki.pot mo ../underlays/locale
13 # Normal mo files for program translation.
14 for file in $(MOFILES); do \
15 lang=`echo $$file | sed 's/\.mo//'`; \
16 install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \
17 install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \
20 # Underlay translation via po files that go in special per-language
22 for file in `cd underlays && find . -type f -name \*.po`; do \
23 lang=`echo $file | sed -e 's/.po$$//' -e 's/.*\\.//'`; \
24 dir=`dirname "$(DESTDIR)$(PREFIX)/share/ikiwiki/po/$$lang"`; \
26 install -m 0644 underlays/$$file $$dir; \
29 ikiwiki.pot: $(POTFILES)
30 @if perl -e '($$ver)=`xgettext -V | head -n 1`=~/.*\s+([0-9]+\.[0-9]+)/; die "gettext $$ver too old, not updating the pot file\n" if $$ver < 0.16'; then \
31 echo "Rebuilding the pot file"; \
32 xgettext --from-code=UTF-8 $(POTFILES) -o ikiwiki.pot -Lperl --add-comments=translators; \
36 rm -f $(MOFILES) messages messages.mo *_stamp
37 rm -rf html underlays/.ikiwiki ../underlays/locale
38 find underlays -name \*.mdwn -or -name \*.pot | xargs rm -f
44 @echo -n "Merging ikiwiki.pot and $@"
45 @msgmerge $@ ikiwiki.pot -o $@.new 2>&1
46 # Typically all that changes was a date or line number. I'd prefer not to
47 # commit such changes, so detect and ignore them.
48 @if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
53 @msgfmt --statistics $@ 2>&1
56 @for file in $(POFILES); do \
57 lang=`echo $$file | sed 's/\.po//'`; \
59 msgfmt -o /dev/null -c -v --statistics $$lang.po;\
63 # copy all the files we want to translate into a srcdir
64 for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
65 install -d $$(dirname $$file); \
66 cp -aL ../$$file $$file 2>/dev/null || \
67 install -m 644 ../$$file $$file; \
69 install -d underlays/directives/ikiwiki/directive
70 for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
71 cp -a ../$$file underlays/directives/ikiwiki/directive || \
72 install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
74 install -d underlays/empty
77 underlays: underlays_copy_stamp
78 ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
80 ../underlays/locale: po2wiki_stamp
81 po2wiki_stamp: po2wiki underlays_copy_stamp
82 PERL5LIB=.. ./po2wiki underlay.setup