Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki.git] / po / Makefile
blobdfb018c81eea6377d901a65d11b783f1de0c6883
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)
13 mo: $(MOFILES)
15 install: all
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; \
21 done
23 # Underlay translation via po files that go in special per-language
24 # underlays.
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"`; \
28 install -d $$dir; \
29 install -m 0644 underlays/$$file $$dir; \
30 done
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; \
38 clean:
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
43 %.mo: %.po
44 msgfmt -o $@ $<
46 %.po: ikiwiki.pot
47 @echo -n "Merging ikiwiki.pot and $@"
48 @msgmerge $@ ikiwiki.pot -o $@.new 2>&1
49 # Typically all that changes was a date or line number. I'd prefer not to
50 # commit such changes, so detect and ignore them.
51 @if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
52 mv -f $@.new $@; \
53 else \
54 rm -f $@.new; \
56 @msgfmt --statistics $@ 2>&1
58 check:
59 @for file in $(POFILES); do \
60 lang=`echo $$file | sed 's/\.po//'`; \
61 printf "$$lang: "; \
62 msgfmt -o /dev/null -c -v --statistics $$lang.po;\
63 done
65 underlays_copy_stamp:
66 # copy all the files we want to translate into a srcdir
67 for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
68 install -d $$(dirname $$file); \
69 cp -aL ../$$file $$file 2>/dev/null || \
70 install -m 644 ../$$file $$file; \
71 done
72 install -d underlays/directives/ikiwiki/directive
73 for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
74 cp -a ../$$file underlays/directives/ikiwiki/directive || \
75 install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
76 done
77 install -d underlays/empty
78 touch $@
80 underlays: ../ikiwiki.out underlays_copy_stamp
81 ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
83 ../ikiwiki.out: ../Makefile
84 make -C .. ikiwiki.out
86 ../Makefile: ../Makefile.PL
87 cd .. && ./Makefile.PL
89 $(TRANSLATED_UNDERLAYS): po2wiki_stamp
90 po2wiki_stamp: po2wiki underlays_copy_stamp
91 PERL5LIB=.. ./po2wiki underlay.setup
92 touch $@
94 .PHONY: underlays