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