Home | History | Annotate | Line # | Download | only in po
      1 # Example for use of GNU gettext.
      2 # Copyright (C) 2003-2006 Free Software Foundation, Inc.
      3 # This file is in the public domain.
      4 #
      5 # Makefile configuration - processed by automake.
      6 
      7 # List of files which contain translatable strings.
      8 POTFILES = \
      9   hello-1.pl.in hello-2.pl.in
     10 
     11 # Usually the message domain is the same as the package name.
     12 DOMAIN = $(PACKAGE)
     13 
     14 # These options get passed to xgettext.
     15 XGETTEXT_OPTIONS = \
     16   -k_ --flag=_:1:pass-perl-format --flag=_:1:pass-perl-brace-format \
     17   -k__ --flag=__:1:pass-perl-format --flag=__:1:pass-perl-brace-format \
     18   -k'$$__' --flag='$$__:1:pass-perl-format' --flag='$$__:1:pass-perl-brace-format' \
     19   -k'%__' --flag=%__:1:pass-perl-format --flag=%__:1:pass-perl-brace-format \
     20   -k__x --flag=__x:1:perl-brace-format \
     21   -k__n:1,2 --flag=__n:1:pass-perl-format --flag=__n:1:pass-perl-brace-format \
     22             --flag=__n:2:pass-perl-format --flag=__n:2:pass-perl-brace-format \
     23   -k__nx:1,2 --flag=__nx:1:perl-brace-format --flag=__nx:2:perl-brace-format \
     24   -k__xn:1,2 --flag=__xn:1:perl-brace-format --flag=__xn:2:perl-brace-format \
     25   -kN__ --flag=N__:1:pass-perl-format --flag=N__:1:pass-perl-brace-format
     26 
     27 # This is the copyright holder that gets inserted into the header of the
     28 # $(DOMAIN).pot file.  Set this to the copyright holder of the surrounding
     29 # package.  (Note that the msgstr strings, extracted from the package's
     30 # sources, belong to the copyright holder of the package.)  Translators are
     31 # expected to transfer the copyright for their translations to this person
     32 # or entity, or to disclaim their copyright.  The empty string stands for
     33 # the public domain; in this case the translators are expected to disclaim
     34 # their copyright.
     35 COPYRIGHT_HOLDER = Yoyodyne, Inc.
     36 
     37 # This is the email address or URL to which the translators shall report
     38 # bugs in the untranslated strings:
     39 # - Strings which are not entire sentences, see the maintainer guidelines
     40 #   in the GNU gettext documentation, section 'Preparing Strings'.
     41 # - Strings which use unclear terms or require additional context to be
     42 #   understood.
     43 # - Strings which make invalid assumptions about notation of date, time or
     44 #   money.
     45 # - Pluralisation problems.
     46 # - Incorrect English spelling.
     47 # - Incorrect formatting.
     48 # It can be your email address, or a mailing list address where translators
     49 # can write to without being subscribed, or the URL of a web page through
     50 # which the translators can contact you.
     51 MSGID_BUGS_ADDRESS = bug-gnu-gettext (a] gnu.org
     52 
     53 # This is the list of locale categories, beyond LC_MESSAGES, for which the
     54 # message catalogs shall be used.  It is usually empty.
     55 EXTRA_LOCALE_CATEGORIES =
     56 
     57 MSGMERGE = msgmerge
     58 MSGMERGE_UPDATE = @MSGMERGE@ --update
     59 MSGINIT = msginit
     60 MSGCONV = msgconv
     61 MSGFILTER = msgfilter
     62 
     63 # This is computed as $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
     64 POTFILES_DEPS = @POTFILES_DEPS@
     65 
     66 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).po)
     67 POFILES = @POFILES@
     68 # This is computed as $(foreach lang, $(LINGUAS), $(srcdir)/$(lang).gmo)
     69 GMOFILES = @GMOFILES@
     70 # This is computed as $(foreach lang, $(LINGUAS), $(lang).po-update)
     71 UPDATEPOFILES = @UPDATEPOFILES@
     72 # This is computed as $(foreach lang, $(LINGUAS), $(lang).nop)
     73 DUMMYPOFILES = @DUMMYPOFILES@
     74 
     75 # This is computed as
     76 # $(foreach lang, user-specified subset of $(LINGUAS), $(lang).gmo)
     77 CATALOGS = @CATALOGS@
     78 
     79 SUFFIXES = .po .gmo .mo .sed .sin .nop .po-create .po-update
     80 
     81 .po.mo:
     82 	@echo "$(MSGFMT) -c -o $@ $<"; \
     83 	$(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
     84 
     85 .po.gmo:
     86 	@lang=`echo $* | sed -e 's,.*/,,'`; \
     87 	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
     88 	echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \
     89 	cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
     90 
     91 .sin.sed:
     92 	sed -e '/^#/d' $< > t-$@
     93 	mv t-$@ $@
     94 
     95 
     96 all-local: all-local-@USE_NLS@
     97 
     98 all-local-yes: stamp-po
     99 all-local-no:
    100 
    101 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
    102 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
    103 # we don't want to bother translators with empty POT files). We assume that
    104 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
    105 # In this case, stamp-po is a nop (i.e. a phony target).
    106 
    107 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
    108 # been loosely updated. Its purpose is that when a developer or translator
    109 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
    110 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
    111 # invocations of "make" will do nothing. This timestamp would not be necessary
    112 # if updating the $(CATALOGS) would always touch them; however, the rule for
    113 # $(POFILES) has been designed to not touch files that don't need to be
    114 # changed.
    115 stamp-po: $(srcdir)/$(DOMAIN).pot
    116 	test ! -f $(srcdir)/$(DOMAIN).pot || \
    117 	  test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
    118 	@test ! -f $(srcdir)/$(DOMAIN).pot || { \
    119 	  echo "touch stamp-po" && \
    120 	  echo timestamp > stamp-poT && \
    121 	  mv stamp-poT stamp-po; \
    122 	}
    123 
    124 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
    125 # otherwise packages like GCC can not be built if only parts of the source
    126 # have been downloaded.
    127 
    128 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
    129 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
    130 $(DOMAIN).pot-update: $(POTFILES_DEPS) remove-potcdate.sed
    131 	if test -n '$(MSGID_BUGS_ADDRESS)'; then \
    132 	  msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
    133 	else \
    134 	  msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
    135 	fi; \
    136 	$(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
    137 	  --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
    138 	  --copyright-holder='$(COPYRIGHT_HOLDER)' \
    139 	  --msgid-bugs-address="$$msgid_bugs_address" \
    140 	  $(POTFILES)
    141 	test ! -f $(DOMAIN).po || { \
    142 	  if test -f $(srcdir)/$(DOMAIN).pot; then \
    143 	    sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
    144 	    sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
    145 	    if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
    146 	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
    147 	    else \
    148 	      rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
    149 	      mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
    150 	    fi; \
    151 	  else \
    152 	    mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
    153 	  fi; \
    154 	}
    155 
    156 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
    157 # every "make" invocation, only create it when it is missing.
    158 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
    159 $(srcdir)/$(DOMAIN).pot:
    160 	$(MAKE) $(DOMAIN).pot-update
    161 
    162 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
    163 # Note that a PO file is not touched if it doesn't need to be changed.
    164 $(POFILES): $(srcdir)/$(DOMAIN).pot
    165 	@lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
    166 	if test -f "$(srcdir)/$${lang}.po"; then \
    167 	  test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
    168 	  echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \
    169 	  cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot; \
    170 	else \
    171 	  $(MAKE) $${lang}.po-create; \
    172 	fi
    173 
    174 
    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 
    218 installdirs-local: installdirs-local-@USE_NLS@
    219 installdirs-local-no:
    220 installdirs-local-yes:
    221 	$(mkdir_p) $(DESTDIR)$(datadir)
    222 	@catalogs='$(CATALOGS)'; \
    223 	for cat in $$catalogs; do \
    224 	  cat=`basename $$cat`; \
    225 	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
    226 	  dir=$(localedir)/$$lang/LC_MESSAGES; \
    227 	  $(mkdir_p) $(DESTDIR)$$dir; \
    228 	  for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
    229 	    if test -n "$$lc"; then \
    230 	      if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
    231 	        link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
    232 	        mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    233 	        mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    234 	        (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
    235 	         for file in *; do \
    236 	           if test -f $$file; then \
    237 	             ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
    238 	           fi; \
    239 	         done); \
    240 	        rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
    241 	      else \
    242 	        if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
    243 	          :; \
    244 	        else \
    245 	          rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
    246 	          mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
    247 	        fi; \
    248 	      fi; \
    249 	    fi; \
    250 	  done; \
    251 	done
    252 
    253 uninstall-local: uninstall-local-@USE_NLS@
    254 uninstall-local-no:
    255 uninstall-local-yes:
    256 	catalogs='$(CATALOGS)'; \
    257 	for cat in $$catalogs; do \
    258 	  cat=`basename $$cat`; \
    259 	  lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
    260 	  for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
    261 	    rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
    262 	  done; \
    263 	done
    264 
    265 html ID:
    266 
    267 MOSTLYCLEANFILES =
    268 MOSTLYCLEANFILES += remove-potcdate.sed
    269 MOSTLYCLEANFILES += stamp-poT
    270 MOSTLYCLEANFILES += core core.* *.stackdump $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
    271 MOSTLYCLEANFILES += *.o
    272 
    273 DISTCLEANFILES = *.mo
    274 
    275 MAINTAINERCLEANFILES = stamp-po $(GMOFILES)
    276 
    277 EXTRA_DIST = remove-potcdate.sin LINGUAS $(POFILES) $(GMOFILES)
    278 
    279 # Hidden from automake, but really activated. Works around an automake-1.5 bug.
    280 #distdir: distdir1
    281 distdir1:
    282 	$(MAKE) update-po
    283 	if test -f $(srcdir)/$(DOMAIN).pot; then \
    284 	  for file in $(DOMAIN).pot stamp-po; do \
    285 	    if test -f $$file; then d=.; else d=$(srcdir); fi; \
    286 	    cp -p $$d/$$file $(distdir)/$$file || exit 1; \
    287 	  done; \
    288 	fi
    289 
    290 update-po: Makefile
    291 	$(MAKE) $(DOMAIN).pot-update
    292 	test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
    293 	$(MAKE) update-gmo
    294 
    295 # General rule for creating PO files.
    296 
    297 .nop.po-create:
    298 	@lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
    299 	echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
    300 	exit 1
    301 
    302 # General rule for updating PO files.
    303 
    304 .nop.po-update:
    305 	@lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
    306 	tmpdir=`pwd`; \
    307 	echo "$$lang:"; \
    308 	test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
    309 	echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
    310 	cd $(srcdir); \
    311 	if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \
    312 	  if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
    313 	    rm -f $$tmpdir/$$lang.new.po; \
    314 	  else \
    315 	    if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
    316 	      :; \
    317 	    else \
    318 	      echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
    319 	      exit 1; \
    320 	    fi; \
    321 	  fi; \
    322 	else \
    323 	  echo "msgmerge for $$lang.po failed!" 1>&2; \
    324 	  rm -f $$tmpdir/$$lang.new.po; \
    325 	fi
    326 
    327 $(DUMMYPOFILES):
    328 
    329 update-gmo: Makefile $(GMOFILES)
    330 	@:
    331