diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-07-08 22:08:04 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-07-08 22:08:04 -0400 |
commit | bcc12b176fc19070aa16940ff4840830bc2ecd59 (patch) | |
tree | d106ea6a95d4fa20d8ccfce16d797df4ba425d9b | |
parent | afc6093ea5b87d2d4c870cef7ef66548d3d576ba (diff) |
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.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | po/.gitignore | 1 | ||||
-rw-r--r-- | po/HACKING | 23 | ||||
-rw-r--r-- | po/Makefile | 11 | ||||
l--------- | po/es/Makefile | 1 | ||||
-rw-r--r-- | po/subdir.mk | 17 |
6 files changed, 44 insertions, 11 deletions
@@ -54,6 +54,6 @@ libretools.out.confs = libretools.out = $(foreach pkg,$(pkgs),po/$(pkg).pot) files.src.gen += .srcversion-libretools.mk .srcversion-devtools.mk -nested.subdirs = $(foreach pkg,$(pkgs),$(pkg.$(pkg))) +nested.subdirs = $(foreach pkg,$(pkgs),$(pkg.$(pkg))) po include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/po/.gitignore b/po/.gitignore index e3a8c5d..514b3d0 100644 --- a/po/.gitignore +++ b/po/.gitignore @@ -1 +1,2 @@ *.pot +*/*.mo @@ -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: <http://www.lingoes.net/en/translator/langcode.htm> 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 |