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