From bcc12b176fc19070aa16940ff4840830bc2ecd59 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 8 Jul 2017 22:08:04 -0400 Subject: Makefile: add support for compiling and installing localizations This means that the new `po/files.generate` target can be used to build the `.pot` files without doing anything else; we can stop requiring translators to install ruby-ronn. It also means that we can put the `.pot` files in the source tarball, to make it even easier for translators. Unfortunately, it does add the extra step of having to create another symlink when adding a new locale. --- po/subdir.mk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 po/subdir.mk (limited to 'po/subdir.mk') diff --git a/po/subdir.mk b/po/subdir.mk new file mode 100644 index 0000000..6c4120b --- /dev/null +++ b/po/subdir.mk @@ -0,0 +1,17 @@ +include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +locale = $(notdir $(srcdir)) +domains = $(patsubst %.po,%,$(filter %.po,$(files.src.src))) + +$(outdir)/%.mo: $(srcdir)/%.po $(call at.path,../%.po) + msgfmt -o $@ $< + +$(DESTDIR)$(localedir)/$(locale)/LC_MESSAGES/%.mo: $(outdir)/%.mo + install -T -Dm644 '$<' '$@' + +files.out.all += $(addsuffix .mo,$(domains)) +files.sys.all += $(foreach domain,$(domains),$(localedir)/$(locale)/LC_MESSAGES/$(domain).mo) +at.subdirs += .. + +include $(topsrcdir)/build-aux/Makefile.tail.mk -- cgit v1.2.3-54-g00ecf From 371a7e29d5718cadbe7cd1830050487f60946266 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 9 Jul 2017 18:53:55 -0400 Subject: Get it producing .mo files again. --- po/subdir.mk | 2 +- src/lib/messages.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'po/subdir.mk') diff --git a/po/subdir.mk b/po/subdir.mk index 6c4120b..3cddb5d 100644 --- a/po/subdir.mk +++ b/po/subdir.mk @@ -4,7 +4,7 @@ include $(topsrcdir)/build-aux/Makefile.head.mk locale = $(notdir $(srcdir)) domains = $(patsubst %.po,%,$(filter %.po,$(files.src.src))) -$(outdir)/%.mo: $(srcdir)/%.po $(call at.path,../%.po) +$(outdir)/%.mo: $(srcdir)/%.po $(call at.path,$(srcdir)/../%.pot) msgfmt -o $@ $< $(DESTDIR)$(localedir)/$(locale)/LC_MESSAGES/%.mo: $(outdir)/%.mo diff --git a/src/lib/messages.sh b/src/lib/messages.sh index 37ee1b8..f28ce7c 100644 --- a/src/lib/messages.sh +++ b/src/lib/messages.sh @@ -124,7 +124,12 @@ bullet() { # # A heading MUST end with a colon (':'), this is how it knows that it # is a heading. Similarly, a flag MUST NOT end with a colon. -flag() { +# +# NB: The opening curly brace is on a separate line because otherwise +# xgettext gets confused when parsing this file. It's a dumb bug in +# GNU xgettext. +flag() +{ local args=("$@") declare -i flaglen=0 -- cgit v1.2.3-54-g00ecf From 6c17560b9177c3354751bb4716ee1b17ddb3f172 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 9 Jul 2017 20:22:29 -0400 Subject: po: do checks on localizations before compiling them --- po/subdir.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'po/subdir.mk') diff --git a/po/subdir.mk b/po/subdir.mk index 3cddb5d..b9a2575 100644 --- a/po/subdir.mk +++ b/po/subdir.mk @@ -5,7 +5,8 @@ locale = $(notdir $(srcdir)) domains = $(patsubst %.po,%,$(filter %.po,$(files.src.src))) $(outdir)/%.mo: $(srcdir)/%.po $(call at.path,$(srcdir)/../%.pot) - msgfmt -o $@ $< + msgcmp --use-untranslated $< $(word 2,$^) + msgfmt -c -o $@ $< $(DESTDIR)$(localedir)/$(locale)/LC_MESSAGES/%.mo: $(outdir)/%.mo install -T -Dm644 '$<' '$@' -- cgit v1.2.3-54-g00ecf