summaryrefslogtreecommitdiff
path: root/po/Makefile
blob: d67c3a4ffac84247dc033ba85baa2665ebdbf1ee (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. # Normal mo files for program translation.
  10. for file in $(MOFILES); do \
  11. lang=`echo $$file | sed 's/\.mo//'`; \
  12. install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \
  13. install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \
  14. done
  15. # Underlay translation via po files that go in special per-language
  16. # underlays.
  17. for file in `cd underlays && find . -type f -name \*.po`; do \
  18. lang=`echo $$file | sed -e 's/.po$$//' -e 's/.*\\.//'`; \
  19. dir=`dirname "$(DESTDIR)$(PREFIX)/share/ikiwiki/po/$$lang/$$file"`; \
  20. install -d $$dir; \
  21. install -m 0644 underlays/$$file $$dir; \
  22. done
  23. ikiwiki.pot: $(POTFILES)
  24. @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 \
  25. echo "Rebuilding the pot file"; \
  26. xgettext --from-code=UTF-8 $(POTFILES) -o ikiwiki.pot -Lperl --add-comments=translators; \
  27. fi
  28. clean:
  29. rm -f $(MOFILES) messages messages.mo *_stamp
  30. rm -rf html underlays/.ikiwiki ../underlays/locale
  31. find underlays -name \*.mdwn -or -name \*.pot | xargs rm -f
  32. %.mo: %.po
  33. msgfmt -o $@ $<
  34. %.po: ikiwiki.pot
  35. @echo -n "Merging ikiwiki.pot and $@"
  36. @msgmerge $@ ikiwiki.pot -o $@.new 2>&1
  37. # Typically all that changes was a date or line number. I'd prefer not to
  38. # commit such changes, so detect and ignore them.
  39. @if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
  40. mv -f $@.new $@; \
  41. else \
  42. rm -f $@.new; \
  43. fi
  44. @msgfmt --statistics $@ 2>&1
  45. check:
  46. @for file in $(POFILES); do \
  47. lang=`echo $$file | sed 's/\.po//'`; \
  48. printf "$$lang: "; \
  49. msgfmt -o /dev/null -c -v --statistics $$lang.po;\
  50. done
  51. underlays_copy_stamp:
  52. # copy all the files we want to translate into a srcdir
  53. for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
  54. install -d $$(dirname $$file); \
  55. cp -aL ../$$file $$file 2>/dev/null || \
  56. install -m 644 ../$$file $$file; \
  57. done
  58. install -d underlays/directives/ikiwiki/directive
  59. for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
  60. cp -a ../$$file underlays/directives/ikiwiki/directive || \
  61. install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
  62. done
  63. install -d underlays/empty
  64. touch $@
  65. underlays: ../ikiwiki.out underlays_copy_stamp
  66. ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
  67. ../ikiwiki.out: ../Makefile
  68. make -C .. ikiwiki.out
  69. ../Makefile: ../Makefile.PL
  70. cd .. && ./Makefile.PL
  71. ../underlays/locale: po2wiki_stamp
  72. po2wiki_stamp: po2wiki underlays_copy_stamp
  73. PERL5LIB=.. ./po2wiki underlay.setup
  74. touch $@
  75. .PHONY: underlays