1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
# dgit message translation machinery
#
# Translators: there is no need to look at this file. It contains
# complicated machinery which you do not need to understand :-).
# See po/README instead.
# Copyright (C)2018 Ian Jackson
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ----- metaprogramming (translators, please ignore all this) -----
#
# We present translators with a single file po/messages.pot containing
# all the messages for the translated programs in dgit.deb and
# git-debrebase.deb. This also includes the messages from the shared
# perl modules.
#
# But when we make the .debs, we want to ship in each .deb the
# messages for that .deb, only (but including the common parts).
#
# So we generate three intermediate .pots,
# .{dgit,git-debrebase,common}.pot
# and merge them to make messages.pot.
#
# From the translations we generate two .mo files for each output
# language: {dgit,git-debrebase}.mo -- including the common messages.
#
# To avoid dirtying the tree whenever we do `make install',
# we honour SUPPRESS_PO_UPDATE, to be used like this
# make install prefix=$(prefix) SUPPRESS_PO_UPDATE=1
all: messages.pot mofiles
include ../i18n-common.make
.%.potfiles:
$S $e; echo ../$*; $f
.common.potfiles:
$S $e; find ../Debian -name \*.pm; $f
.%.make: .%.potfiles Makefile part.make
$S $e; \
sed 's/~/$*/g' part.make; \
sed "s#^#.$*.pot: #" $<; \
$f
-include .dgit.make
-include .git-debrebase.make
-include .common.make
POFILES := $(wildcard *.po)
LANGS := $(basename $(POFILES))
MOFILES = $(foreach part,$(filter-out common,$(PARTS)), \
$(addprefix mo/$(part)_, $(POFILES:.po=.mo)))
messages.pot: $(if $(SUPPRESS_PO_UPDATE),,$(POTS))
$S msgcat --to-code=UTF-8 $^ >.messages.0.tmp
$S ( ./remove-potcdate <$@ ||: ) >.messages.1.tmp
$S ./remove-potcdate <.messages.0.tmp >.messages.2.tmp
$S cmp -s .messages.[12].tmp || mv -v .messages.0.tmp $@
@echo 'Updated $@.'
%.mo: %.po
$S msgfmt -o $@ $<
XGETTEXT_OPTS += -Lperl -k__ -kf_ -ki_
XGETTEXT_OPTS += --from-code=UTF-8
XGETTEXT_OPTS += --package-name=dgit --package-version=ongoing
# The --package-* avoids this error from make check's `msgfmt -c'
# warning: header field 'Project-Id-Version' still has the initial default value
%.pot:
$S TZ=UTC xgettext $(XGETTEXT_OPTS) $^ -o $@.tmp && $f
mofiles: $(MOFILES)
@echo 'Generated mo/*.mo (binary translated messages) OK.'
install: all
set -e; for file in $(MOFILES); do \
lang=$${file#*_}; lang=$${lang%.mo}; \
part=$${file#mo/}; part=$${part%%_*}; \
d=$(DESTDIR)$(prefix)/share/locale/$$lang/LC_MESSAGES; \
install -d $$d; \
install -m 0644 $$file $$d/$$part.mo; \
done
clean:
rm -f .*.make .*.potfiles .*.pot .*.tmp
rm -rf mo
%.po: $(if $(SUPPRESS_PO_UPDATE),,messages.pot)
@echo -n "Merging messages.pot and $@ "
$S if test -f $@; then \
msgmerge --previous $@ messages.pot -o $@.new; \
else \
msgcat --lang=$* messages.pot >$@.new; \
fi
$S mv -f $@.new $@
$S msgfmt -o /dev/null --statistics $@
.PRECIOUS: .%.potfiles
pofiles: $(POFILES)
update: pofiles check
check: $(if $(SUPPRESS_PO_UPDATE),,pofiles)
$S set -e; for file in $(POFILES); do \
lang=`echo $$file | sed 's/\.po//'`; \
printf "$$lang: "; \
msgfmt -o /dev/null -c -v --statistics $$lang.po;\
done
|