summaryrefslogtreecommitdiff
path: root/po
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-07-30 07:11:29 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-09-28 23:29:24 +0100
commit53d499e549e6eec5e319965cf2df1368120f2bca (patch)
treecab4553278267589447f38672a75f13ad979f679 /po
parente30e757694693211aaab57fb8b300f2c5e54b6b7 (diff)
i18n: Copy po/Makefile and remove-potcdate.plfrom debconf
These are from debconf.git a326240dd50487732d8546858994d48b45bf0b20. There doesn't seem to be a common library for this kind of thing. I'm going to take debconf as a good example and nick the code. Copyright: the debian/copyright file of debconf says it's BSD-2-clause. So add that, and copyright notices based on "git log" (which does seem comprehensive). Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'po')
-rw-r--r--po/Makefile50
-rwxr-xr-xpo/remove-potcdate.pl11
2 files changed, 61 insertions, 0 deletions
diff --git a/po/Makefile b/po/Makefile
new file mode 100644
index 0000000..e5b4bc8
--- /dev/null
+++ b/po/Makefile
@@ -0,0 +1,50 @@
+# List here all source files with translatable strings.
+POTFILES=$(sort $(shell find ../Debconf -type f -name \*.pm)) \
+ ../dpkg-* ../debconf-* ../debconf
+
+POFILES=$(wildcard *.po)
+MOFILES=$(POFILES:.po=.mo)
+
+all: debconf.pot $(MOFILES)
+
+install: all
+ for file in $(MOFILES); do \
+ lang=`echo $$file | sed 's/\.mo//'`; \
+ install -d $(prefix)/usr/share/locale/$$lang/LC_MESSAGES/; \
+ install -m 0644 $$file $(prefix)/usr/share/locale/$$lang/LC_MESSAGES/debconf.mo; \
+ done
+
+debconf.pot: $(POTFILES)
+ @echo "Rebuilding the pot file"
+ TZ=UTC xgettext $(POTFILES) -o debconf.pot.new -Lperl
+ if [ -f debconf.pot ]; then \
+ ./remove-potcdate.pl < debconf.pot > debconf.1po && \
+ ./remove-potcdate.pl < debconf.pot.new > debconf.2po && \
+ if cmp debconf.1po debconf.2po >/dev/null 2>&1; then \
+ rm -f debconf.1po debconf.2po debconf.pot.new; \
+ else \
+ rm -f debconf.1po debconf.2po && \
+ mv debconf.pot.new debconf.pot; \
+ fi; \
+ else \
+ mv debconf.pot.new debconf.pot; \
+ fi
+
+clean:
+ rm -f $(MOFILES) debconf.pot.new messages messages.mo
+
+%.mo: %.po
+ msgfmt -o $@ $<
+
+%.po: debconf.pot
+ @echo -n "Merging debconf.pot and $@"
+ @msgmerge --previous $@ debconf.pot -o $@.new
+ @mv -f $@.new $@
+ @msgfmt --statistics $@
+
+check:
+ @for file in $(POFILES); do \
+ lang=`echo $$file | sed 's/\.po//'`; \
+ printf "$$lang: "; \
+ msgfmt -o /dev/null -c -v --statistics $$lang.po;\
+ done
diff --git a/po/remove-potcdate.pl b/po/remove-potcdate.pl
new file mode 100755
index 0000000..069a1de
--- /dev/null
+++ b/po/remove-potcdate.pl
@@ -0,0 +1,11 @@
+#! /usr/bin/perl -n
+
+BEGIN {
+ $seen_potcdate = 0;
+}
+
+if (not $seen_potcdate and /^"POT-Creation-Date: .*"/) {
+ $seen_potcdate = 1;
+ next;
+}
+print;