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