PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/po/Makefile.am

#
Makefile | 375 lines | 248 code | 47 blank | 80 comment | 83 complexity | 82b97c557c87cd24bcf02b5a09963e41 MD5 | raw file
Possible License(s): AGPL-3.0
  1. # Based on gettext-0.17/gettext-tools/examples/hello-php
  2. # (public domain)
  3. # Changes:
  4. # - some targets at the end, use `find` instead of
  5. # $(POTFILES). $(POTFILES_DEPS) is supposed to do that though.
  6. # - make sure .mo are encoded using UTF-8 for efficiency and/or to
  7. # ease the Savane-specific PHP implementation of the gettext
  8. # runtime.
  9. # - @XGETTEXT_EXTRA_OPTIONS@ is apparently recently introduced in
  10. # autoconf. Let's not use for now.
  11. # - Add $(GMOFILES) to the default target (all-local-yes), so .mo
  12. # files are updated when a .po is modified.
  13. # List of files which contain translatable strings.
  14. # Empty because we use some `find` in $(DOMAIN).opt-update
  15. POTFILES =
  16. # Usually the message domain is the same as the package name.
  17. DOMAIN = $(PACKAGE)
  18. # These options get passed to xgettext.
  19. XGETTEXT_OPTIONS =
  20. # This is the copyright holder that gets inserted into the header of the
  21. # $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
  22. # package. (Note that the msgstr strings, extracted from the package's
  23. # sources, belong to the copyright holder of the package.) Translators are
  24. # expected to transfer the copyright for their translations to this person
  25. # or entity, or to disclaim their copyright. The empty string stands for
  26. # the public domain; in this case the translators are expected to disclaim
  27. # their copyright.
  28. COPYRIGHT_HOLDER = Collective
  29. # This is the email address or URL to which the translators shall report
  30. # bugs in the untranslated strings:
  31. # - Strings which are not entire sentences, see the maintainer guidelines
  32. # in the GNU gettext documentation, section 'Preparing Strings'.
  33. # - Strings which use unclear terms or require additional context to be
  34. # understood.
  35. # - Strings which make invalid assumptions about notation of date, time or
  36. # money.
  37. # - Pluralisation problems.
  38. # - Incorrect English spelling.
  39. # - Incorrect formatting.
  40. # It can be your email address, or a mailing list address where translators
  41. # can write to without being subscribed, or the URL of a web page through
  42. # which the translators can contact you.
  43. MSGID_BUGS_ADDRESS = savane-dev@gna.org
  44. # This is the list of locale categories, beyond LC_MESSAGES, for which the
  45. # message catalogs shall be used. It is usually empty.
  46. EXTRA_LOCALE_CATEGORIES =
  47. MSGMERGE = msgmerge
  48. MSGMERGE_UPDATE = @MSGMERGE@ --update
  49. MSGINIT = msginit
  50. MSGCONV = msgconv
  51. MSGFILTER = msgfilter
  52. # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
  53. POTFILES_DEPS = @POTFILES_DEPS@
  54. # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
  55. POFILES = @POFILES@
  56. # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
  57. GMOFILES = @GMOFILES@
  58. # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
  59. UPDATEPOFILES = @UPDATEPOFILES@
  60. # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
  61. DUMMYPOFILES = @DUMMYPOFILES@
  62. # This is computed as
  63. # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
  64. CATALOGS = @CATALOGS@
  65. SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
  66. # Make sure the .po file is encoded in UTF-8 for efficiency and/or to
  67. # ease the Savane-specific PHP implementation of the gettext
  68. # runtime. I didn't test, it was that way before the autoconfiscation,
  69. # so maybe it's not necessary.
  70. .po.po_utf-8:
  71. msgconv --to-code=UTF-8 --output-file=$@ $<
  72. .po_utf-8.mo:
  73. @echo "$(MSGFMT) -c -o $@ $<"; \
  74. $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
  75. .po_utf-8.gmo:
  76. @lang=`echo $* | sed -e 's,.*/,,'`; \
  77. test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
  78. echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
  79. cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
  80. .sin.sed:
  81. sed -e '/^#/d' $< > t-$@
  82. mv t-$@ $@
  83. all-local: all-local-@USE_NLS@
  84. all-local-yes: stamp-po $(GMOFILES)
  85. all-local-no:
  86. # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
  87. # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
  88. # we don't want to bother translators with empty POT files). We assume that
  89. # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
  90. # In this case, stamp-po is a nop (i.e. a phony target).
  91. # stamp-po is a timestamp denoting the last time at which the CATALOGS have
  92. # been loosely updated. Its purpose is that when a developer or translator
  93. # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
  94. # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
  95. # invocations of "make" will do nothing. This timestamp would not be necessary
  96. # if updating the $(CATALOGS) would always touch them; however, the rule for
  97. # $(POFILES) has been designed to not touch files that don't need to be
  98. # changed.
  99. stamp-po: $(srcdir)/$(DOMAIN).pot
  100. test ! -f $(srcdir)/$(DOMAIN).pot || \
  101. test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
  102. @test ! -f $(srcdir)/$(DOMAIN).pot || { \
  103. echo "touch stamp-po" && \
  104. echo timestamp > stamp-poT && \
  105. mv stamp-poT stamp-po; \
  106. }
  107. # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
  108. # otherwise packages like GCC can not be built if only parts of the source
  109. # have been downloaded.
  110. # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
  111. # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
  112. $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
  113. if LC_ALL=C grep 'GNU $(PACKAGE)' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
  114. package_gnu='GNU '; \
  115. else \
  116. package_gnu=''; \
  117. fi; \
  118. if test -n '$(MSGID_BUGS_ADDRESS)'; then \
  119. msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
  120. else \
  121. msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
  122. fi; \
  123. case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
  124. '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
  125. $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
  126. --language=PHP \
  127. --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
  128. --copyright-holder='$(COPYRIGHT_HOLDER)' \
  129. --msgid-bugs-address="$$msgid_bugs_address" \
  130. $(POTFILES) \
  131. `cd .. && find frontend/php/ -iname "*.php" -or -iname "*.class"` \
  132. ;; \
  133. *) \
  134. $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
  135. --language=PHP \
  136. --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
  137. --copyright-holder='$(COPYRIGHT_HOLDER)' \
  138. --package-name="$${package_gnu}$(PACKAGE)" \
  139. --package-version='$(VERSION)' \
  140. --msgid-bugs-address="$$msgid_bugs_address" \
  141. $(POTFILES) \
  142. `cd .. && find frontend/php/ -iname "*.php" -or -iname "*.class"` \
  143. ;; \
  144. esac
  145. test ! -f $(DOMAIN).po || { \
  146. if test -f $(srcdir)/$(DOMAIN).pot; then \
  147. sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
  148. sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
  149. if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
  150. rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
  151. else \
  152. rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
  153. mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
  154. fi; \
  155. else \
  156. mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
  157. fi; \
  158. }
  159. # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
  160. # every "make" invocation, only create it when it is missing.
  161. # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
  162. $(srcdir)/$(DOMAIN).pot:
  163. $(MAKE) $(DOMAIN).pot-update
  164. # This target rebuilds a PO file if $(DOMAIN).pot has changed.
  165. # Note that a PO file is not touched if it doesn't need to be changed.
  166. $(POFILES): $(srcdir)/$(DOMAIN).pot
  167. @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
  168. if test -f "$(srcdir)/$${lang}.po"; then \
  169. test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
  170. echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
  171. cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
  172. else \
  173. $(MAKE) $${lang}.po-create; \
  174. fi
  175. install-data-local: install-data-local-@USE_NLS@
  176. install-data-local-no: all-local
  177. install-data-local-yes: all-local
  178. $(mkdir_p) $(DESTDIR)$(datadir)
  179. @catalogs='$(CATALOGS)'; \
  180. for cat in $$catalogs; do \
  181. cat=`basename $$cat`; \
  182. lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
  183. dir=$(localedir)/$$lang/LC_MESSAGES; \
  184. $(mkdir_p) $(DESTDIR)$$dir; \
  185. if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
  186. $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
  187. echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
  188. for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
  189. if test -n "$$lc"; then \
  190. if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
  191. link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
  192. mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
  193. mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
  194. (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
  195. for file in *; do \
  196. if test -f $$file; then \
  197. ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
  198. fi; \
  199. done); \
  200. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
  201. else \
  202. if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
  203. :; \
  204. else \
  205. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
  206. mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
  207. fi; \
  208. fi; \
  209. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
  210. ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
  211. ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
  212. cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
  213. echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
  214. fi; \
  215. done; \
  216. done
  217. installdirs-local: installdirs-local-@USE_NLS@
  218. installdirs-local-no:
  219. installdirs-local-yes:
  220. $(mkdir_p) $(DESTDIR)$(datadir)
  221. @catalogs='$(CATALOGS)'; \
  222. for cat in $$catalogs; do \
  223. cat=`basename $$cat`; \
  224. lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
  225. dir=$(localedir)/$$lang/LC_MESSAGES; \
  226. $(mkdir_p) $(DESTDIR)$$dir; \
  227. for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
  228. if test -n "$$lc"; then \
  229. if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
  230. link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
  231. mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
  232. mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
  233. (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
  234. for file in *; do \
  235. if test -f $$file; then \
  236. ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
  237. fi; \
  238. done); \
  239. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
  240. else \
  241. if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
  242. :; \
  243. else \
  244. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
  245. mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
  246. fi; \
  247. fi; \
  248. fi; \
  249. done; \
  250. done
  251. uninstall-local: uninstall-local-@USE_NLS@
  252. uninstall-local-no:
  253. uninstall-local-yes:
  254. catalogs='$(CATALOGS)'; \
  255. for cat in $$catalogs; do \
  256. cat=`basename $$cat`; \
  257. lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
  258. for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
  259. rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
  260. done; \
  261. done
  262. html ID:
  263. MOSTLYCLEANFILES =
  264. MOSTLYCLEANFILES += remove-potcdate.sed
  265. MOSTLYCLEANFILES += stamp-poT
  266. MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
  267. MOSTLYCLEANFILES += *.o
  268. DISTCLEANFILES = *.mo
  269. MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
  270. EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
  271. # Hidden from automake, but really activated. Works around an automake-1.5 bug.
  272. #distdir: distdir1
  273. distdir1:
  274. $(MAKE) update-po
  275. if test -f $(srcdir)/$(DOMAIN).pot; then \
  276. for file in $(DOMAIN).pot stamp-po; do \
  277. if test -f $$file; then d=.; else d=$(srcdir); fi; \
  278. cp -p $$d/$$file $(distdir)/$$file || exit 1; \
  279. done; \
  280. fi
  281. update-po: Makefile
  282. $(MAKE) $(DOMAIN).pot-update
  283. test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
  284. $(MAKE) update-gmo
  285. # General rule for creating PO files.
  286. .nop.po-create:
  287. @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
  288. echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
  289. exit 1
  290. # General rule for updating PO files.
  291. .nop.po-update:
  292. @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
  293. tmpdir=`pwd`; \
  294. echo "$$lang:"; \
  295. test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
  296. echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
  297. cd $(srcdir); \
  298. if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
  299. if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
  300. rm -f $$tmpdir/$$lang.new.po; \
  301. else \
  302. if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
  303. :; \
  304. else \
  305. echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
  306. exit 1; \
  307. fi; \
  308. fi; \
  309. else \
  310. echo "msgmerge for $$lang.po failed!" 1>&2; \
  311. rm -f $$tmpdir/$$lang.new.po; \
  312. fi
  313. $(DUMMYPOFILES):
  314. update-gmo: Makefile $(GMOFILES)
  315. @:
  316. ########
  317. # Compatibility with the previous Makefile
  318. stats: report
  319. report:
  320. @for cat in $(POFILES); do \
  321. echo "$$cat:"; \
  322. echo -n " "; \
  323. msgfmt -v --check --statistics --output-file=/dev/null $$cat; \
  324. done
  325. potfile: $(DOMAIN).pot-update
  326. refresh-po: potfile
  327. ask-update:
  328. if [ -e /usr/bin/podebconf-report-po ]; then /usr/bin/podebconf-report-po --package=savane --podir=. --from="savane-dev-i18n@gna.org" --package="Savane" --template=../devel/updatepo-template.txt ; else echo " " && echo "podebconf-report-po not found, not able to ask to translators to update"; fi