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 # Translated underlays can only be generated if po4a is available.
9 TRANSLATED_UNDERLAYS=$(shell if perl -e 'use Locale::Po4a::Common' 2>/dev/null; then echo ../underlays/locale; fi)
11 all: ikiwiki.pot mo $(TRANSLATED_UNDERLAYS)
16 # Normal mo files for program translation.
17 for file in $(MOFILES); do \
18 lang=`echo $$file | sed 's/\.mo//'`; \
19 install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \
20 install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \
23 # Underlay translation via po files that go in special per-language
25 for file in `cd underlays && find . -type f -name \*.po`; do \
26 lang=`echo $$file | sed -e 's/.po$$//' -e 's/.*\\.//'`; \
27 dir=`dirname "$(DESTDIR)$(PREFIX)/share/ikiwiki/po/$$lang/$$file"`; \
29 install -m 0644 underlays/$$file $$dir; \
32 ikiwiki.pot: $(POTFILES)
33 @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 \
34 echo "Rebuilding the pot file"; \
35 xgettext --from-code=UTF-8 $(POTFILES) -o ikiwiki.pot -Lperl --add-comments=translators; \
39 rm -f $(MOFILES) messages messages.mo *_stamp
40 rm -rf html underlays/.ikiwiki $(TRANSLATED_UNDERLAYS)
41 find underlays -name \*.mdwn -or -name \*.pot | xargs rm -f
44 @if ! msgfmt -o $@ $<; then echo "unable to run msgfmt"; fi
47 @echo -n "Merging ikiwiki.pot and $@"
48 # Typically all that changes is a date or line number. I'd prefer not to
49 # commit such changes, so detect and ignore them.
50 @if ! msgmerge $@ ikiwiki.pot -o $@.new 2>&1; then \
51 echo "unable to run msgmerge"; \
53 if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
58 msgfmt --statistics $@ 2>&1; \
62 @for file in $(POFILES); do \
63 lang=`echo $$file | sed 's/\.po//'`; \
65 msgfmt -o /dev/null -c -v --statistics $$lang.po;\
69 # copy all the files we want to translate into a srcdir
70 for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
71 install -d $$(dirname $$file); \
72 cp -aL ../$$file $$file 2>/dev/null || \
73 install -m 644 ../$$file $$file; \
75 install -d underlays/directives/ikiwiki/directive
76 for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
77 cp -a ../$$file underlays/directives/ikiwiki/directive || \
78 install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
80 install -d underlays/empty
83 underlays: ../ikiwiki.out underlays_copy_stamp
84 ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
86 ../ikiwiki.out: ../Makefile
87 $(MAKE) -C .. ikiwiki.out
89 ../Makefile: ../Makefile.PL
90 cd .. && ./Makefile.PL
92 $(TRANSLATED_UNDERLAYS): po2wiki_stamp
93 po2wiki_stamp: po2wiki underlays_copy_stamp
94 PERL5LIB=.. ./po2wiki underlay.setup