]> sipb.mit.edu Git - ikiwiki.git/blob - po/Makefile
Merge branch 'master' into sipb
[ikiwiki.git] / po / Makefile
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
4
5 POFILES=$(wildcard *.po)
6 MOFILES=$(POFILES:.po=.mo)
7
8 all: ikiwiki.pot mo
9
10 mo: $(MOFILES)
11
12 install: all
13         for file in $(MOFILES); do \
14                 lang=`echo $$file | sed 's/\.mo//'`; \
15                 install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \
16                 install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \
17         done
18
19 ikiwiki.pot: $(POTFILES)
20         @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 \
21                 echo "Rebuilding the pot file"; \
22                 xgettext --from-code=UTF-8 $(POTFILES) -o ikiwiki.pot -Lperl --add-comments=translators; \
23         fi
24
25 clean:
26         rm -f $(MOFILES) messages messages.mo
27
28 %.mo: %.po
29         @if ! msgfmt -o $@ $<; then echo "unable to run msgfmt"; fi
30
31 %.po: ikiwiki.pot
32         @echo -n "Merging ikiwiki.pot and $@"
33 # Typically all that changes is a date or line number. I'd prefer not to
34 # commit such changes, so detect and ignore them.
35         @if ! msgmerge $@ ikiwiki.pot -o $@.new 2>&1; then \
36                 echo "unable to run msgmerge"; \
37         else \
38                 if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
39                         mv -f $@.new $@; \
40                 else \
41                         rm -f $@.new; \
42                 fi; \
43                 msgfmt --statistics $@ 2>&1; \
44         fi
45
46 check:
47         @for file in $(POFILES); do \
48                 lang=`echo $$file | sed 's/\.po//'`; \
49                 printf "$$lang: "; \
50                 msgfmt -o /dev/null -c -v --statistics $$lang.po;\
51         done