summaryrefslogtreecommitdiff
path: root/po/Makefile
blob: cef2ec87977baec52ebdf5c6c294428660d67b0e (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 ../underlays/locale
  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 *_stamp
  21. rm -rf html underlays/.ikiwiki ../underlays/locale
  22. find underlays -name \*.mdwn | xargs rm -f
  23. %.mo: %.po
  24. msgfmt -o $@ $<
  25. %.po: ikiwiki.pot
  26. @echo -n "Merging ikiwiki.pot and $@"
  27. @msgmerge $@ ikiwiki.pot -o $@.new 2>&1
  28. # Typically all that changes was a date or line number. I'd prefer not to
  29. # commit such changes, so detect and ignore them.
  30. @if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
  31. mv -f $@.new $@; \
  32. else \
  33. rm -f $@.new; \
  34. fi
  35. @msgfmt --statistics $@ 2>&1
  36. check:
  37. @for file in $(POFILES); do \
  38. lang=`echo $$file | sed 's/\.po//'`; \
  39. printf "$$lang: "; \
  40. msgfmt -o /dev/null -c -v --statistics $$lang.po;\
  41. done
  42. underlays_copy_stamp:
  43. # copy all the files we want to translate into a srcdir
  44. for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
  45. install -d $$(dirname $$file); \
  46. cp -aL ../$$file $$file 2>/dev/null || \
  47. install -m 644 ../$$file $$file; \
  48. done
  49. install -d underlays/directives/ikiwiki/directive
  50. for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
  51. cp -a ../$$file underlays/directives/ikiwiki/directive || \
  52. install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
  53. done
  54. touch $@
  55. underlays: underlays_copy_stamp
  56. install -d underlays/empty
  57. ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
  58. ../underlays/locale: po2wiki_stamp
  59. po2wiki_stamp: po2wiki underlays_copy_stamp
  60. PERL5LIB=.. ./po2wiki underlay.setup
  61. touch $@
  62. .PHONY: underlays