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