diff options
author | Wolfgang Müller | 2021-06-26 15:32:40 +0200 |
---|---|---|
committer | Wolfgang Müller | 2021-06-27 18:31:06 +0200 |
commit | e03fdccc4e191e0e7cd60b4fef9e6f603ccc112b (patch) | |
tree | aede7a26eb41b0a8066016f471448289391d85c8 /Makefile | |
parent | b70083a5f4404e2422ff0a0aadd023a661164fae (diff) | |
download | weltschmerz-e03fdccc4e191e0e7cd60b4fef9e6f603ccc112b.tar.gz |
Prepare for internationalization
weltschmerz currently does not allow for translation and exists in
English only. This is a serious defect for people who do not speak that
language. The following series of commits aims to remedy this by adding
the necessary infrastructure and build steps to enable easy translation.
To do this we use GNU gettext[1]; its tooling is widely supported and a
de-facto standard. Since we need to tell gettext where to find the
compiled .mo translation files, have both the Makefile and meson pass
the locale directory to weltschmerz in form of a LOCALEDIR macro. The
translation domain will be "weltschmerz".
Not only will any strings in the Vala code have to be translated, we
need to make sure to translate terminal.ui and weltschmerz.desktop as
well. The former will be taken care of through POTFILES only, but for
the latter we have to define an intermediary build step. To ensure
compatibility with the Makefile, we suffix the desktop file with '.in'.
For now, LINGUAS and POTFILES remain empty. A future commit will
document all files needing translation. LINGUAS will be updated as
translations are completed.
[1] https://www.gnu.org/software/gettext
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -2,22 +2,38 @@ PREFIX ?= /usr/local EXEC_PREFIX ?= ${PREFIX} BINDIR ?= ${EXEC_PREFIX}/bin DATAROOTDIR ?= ${PREFIX}/share +LOCALEDIR ?= ${DATAROOTDIR}/locale MANDIR ?= ${DATAROOTDIR}/man VALAC ?= valac +POFILES := $(wildcard po/*.po) +MOFILES := $(POFILES:.po=.mo) + weltschmerz: weltschmerz.vala terminal.vala config.vala configreader.vala utils.vala resources.c - ${VALAC} -X -lm --pkg posix --pkg gtk+-3.0 --pkg vte-2.91 --gresources resources.xml \ + ${VALAC} -X -DGETTEXT_PACKAGE=\"weltschmerz\" -X -DLOCALEDIR="\"${LOCALEDIR}\"" \ + -X -lm --pkg posix --pkg gtk+-3.0 --pkg vte-2.91 --gresources resources.xml \ weltschmerz.vala terminal.vala config.vala configreader.vala utils.vala resources.c resources.c: resources.xml terminal.ui terminal.css glib-compile-resources $< --target=$@ --generate-source -install: weltschmerz weltschmerz.1 weltschmerz.desktop +%.mo: %.po + msgfmt $< -o $@ + +weltschmerz.desktop: weltschmerz.desktop.in + msgfmt --desktop -d po --template $< -o $@ + +install: weltschmerz weltschmerz.1 weltschmerz.desktop $(MOFILES) install -D -m 755 -t '${DESTDIR}${BINDIR}' weltschmerz install -D -m 644 -t '${DESTDIR}${MANDIR}/man1' weltschmerz.1 install -D -m 644 -t '${DESTDIR}${DATAROOTDIR}/applications' weltschmerz.desktop + for mo in $(MOFILES); do \ + lang=$$(basename "$$mo" .mo); \ + install -D -m 644 "$$mo" "${DESTDIR}${LOCALEDIR}/$$lang/LC_MESSAGES/weltschmerz.mo"; \ + done clean: - rm -f weltschmerz resources.c + rm -f weltschmerz weltschmerz.desktop resources.c + rm -f po/*.mo .PHONY: install clean |