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/.gitignore | 1 + po/HACKING | 23 +++++++++++++---------- po/Makefile | 11 +++++++++++ po/es/Makefile | 1 + po/subdir.mk | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 po/Makefile create mode 120000 po/es/Makefile create mode 100644 po/subdir.mk (limited to 'po') diff --git a/po/.gitignore b/po/.gitignore index e3a8c5d..514b3d0 100644 --- a/po/.gitignore +++ b/po/.gitignore @@ -1 +1,2 @@ *.pot +*/*.mo diff --git a/po/HACKING b/po/HACKING index 9ab35a7..5dd207c 100644 --- a/po/HACKING +++ b/po/HACKING @@ -2,23 +2,24 @@ Translations for programs are provided in files with the `.po` suffix. These are created by copying PO-template (`.pot`) files, and filling in the missing "msgstr" values. -To add a translation, you'll first (1) need to create the `.pot` -files, and then (2) copy them and (3) fill them in. +To add a translation, you'll first (1) need to create the `.pot` files +if you don't already have them, and then (2) copy them and (3) fill +them in. # 1. Create `.pot` files + If you are working from a release source tarball, you can skip this + step (the `.pot` files are included in the tarball); if you are + working from git, read on. + libretools' .pot files are not tracked in git; they are created by - running `make` (you'll need a checkout of both devtools-par and - libretools to run `make` if building from git). In addition to the - usual (`base-devel`) depenencies when running `make`, you'll need - the `ruby-ronn` package as well. + running `make`. You'll need a checkout of both "devtools-par" and + "libretools" to run `make` if building from git. - $ sudo pacman -S --needed base-devel ruby-ronn - ... $ git clone https://git.parabola.nu/packages/devtools-par.git/ $ git clone https://git.parabola.nu/packages/libretools.git/ $ cd libretools - $ make + $ make po/files.generate ... $ cd po/ $ ls @@ -33,10 +34,12 @@ files, and then (2) copy them and (3) fill them in. Create a folder under `po/` with the two-letter language code[^1] you want to add. Then, copy the `.pot` files to that folder, - changing the file extension to `.po`; for example: + changing the file extension to `.po`. Finally, link the `subdir.mk` + file to be the Makefile for that directory. For example: $ mkdir es $ for file in *.pot; do cp $file es/${file%t}; done + $ ln -s ../subdir.mk es/Makefile [^1]: See the langauge code table here: diff --git a/po/Makefile b/po/Makefile new file mode 100644 index 0000000..1e56edd --- /dev/null +++ b/po/Makefile @@ -0,0 +1,11 @@ +include $(dir $(lastword $(MAKEFILE_LIST)))/../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +domains = libretools librelib gitget xbs +locales := $(filter-out .,$(sort $(patsubst %/,%,$(dir $(files.src.src))))) + +files.src.gen += $(addsuffix .pot,$(domains)) +nested.subdirs += $(locales) +at.subdirs += .. + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/po/es/Makefile b/po/es/Makefile new file mode 120000 index 0000000..71a1159 --- /dev/null +++ b/po/es/Makefile @@ -0,0 +1 @@ +../subdir.mk \ No newline at end of file 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.2