Skip to content
Snippets Groups Projects
Verified Commit aac28343 authored by Karel Koci's avatar Karel Koci :metal:
Browse files

Rework Makefile

This improves makefile. The primary change here is the functionality of
merging changes from pot file to all po files. This is required because
Weblate does not do it automatically and we want to always translate the
latest version of strings so we want always to merge new changes.
parent f7f471db
No related merge requests found
Showing
with 46 additions and 35 deletions
*.mo
......@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- packages: limit updater keys we query to `/etc/updater/keys/*.pub` thus
ignoring the `*.pub.sig` files that are also stored there.
- `Makefile` used to manage translations was improved.
## [14.0.0] - 2021-06-01
......
.PHONY: all clean messages install
MAKEFLAGS += --no-builtin-rules
all:
@echo usage:
@echo " make messages"
@echo " make install"
@echo " make clean"
LANGS:=$(shell find locale -name turris-diagnostics.po | cut -d '/' -f 2)
MO:=$(patsubst %.po,%.mo,$(shell find -name turris-diagnostics.po))
clean:
rm -rf locale/*/LC_MESSAGES/turris-diagnostics.mo
rm -rf locale/*/LC_MESSAGES/turris-diagnostics.po~
.PHONY: all
all: $(MO)
@
LANGS:=$(shell ls -1 locale | grep -v diagnostics.pot)
INSTALL_TARGET:=/usr/share
.PHONY: clean
clean:
rm -f $(MO)
# make messages
#
locale/turris-diagnostics.pot: diagnostics.sh modules/*.module
mkdir -p locale/
cat diagnostics.sh $^ | xgettext --package-name=turris-diagnostics -d turris-diagnostics --no-location --language=Shell --output=$@ -
.PHONY: install
install:
@
define UPDATE_TRANSLATION
.PHONY: update
update:
@
locale/$(1)/LC_MESSAGES/turris-diagnostics.po: locale/turris-diagnostics.pot
if [ -e "$$@" ] ; then msgmerge --update --lang=$(1) --no-location $$@ $$< ; else msginit -i $$< -l $(1) --no-translator -o $$@ ; fi
.PHONY: help
help:
@echo 'Top level targets:'
@echo ' all: generate *.mo files'
@echo ' clean: remove generated *.mo files'
@echo ' install: copy *.mo files to $$(DESTDIR)/usr/share/locale/'
@echo ' update: extract strings and merge changes from *.pot file to *.po files'
endef
$(foreach LANG, $(LANGS), $(eval $(call UPDATE_TRANSLATION,$(LANG))))
$(MO): %.mo: %.po
msgfmt --output-file=$@ $<
messages: $(foreach LANG, $(LANGS), locale/$(LANG)/LC_MESSAGES/turris-diagnostics.po)
locale/turris-diagnostics.pot: diagnostics.sh modules/*.module
@mkdir -p "$(@D)"
xgettext --package-name=turris-diagnostics -d turris-diagnostics --no-location --language=Shell --output=$@ $^
# make install
#
define COMPILE_MESSAGES
define CASEDEF_LANG
locale/$(1)/LC_MESSAGES/turris-diagnostics.mo: locale/$(1)/LC_MESSAGES/turris-diagnostics.po
msgfmt -o $$@ $$<
locale/$(1)/turris-diagnostics.po: locale/turris-diagnostics.pot
msgmerge --backup off --update "$$@" "$$<"
endef
.PHONY: install-$(1)
install: install-$(1)
install-$(1): locale/$(1)/turris-diagnostics.mo
install -D $$< $$(DESTDIR)/usr/share/locale/$(1)/LC_MESSAGES/turris-diagnostics.mo
$(foreach LANG, $(LANGS), $(eval $(call COMPILE_MESSAGES,$(LANG))))
.PHONY: update-$(1)
update: update-$(1)
update-$(1): locale/$(1)/turris-diagnostics.po
@
install: $(foreach LANG, $(LANGS), locale/$(LANG)/LC_MESSAGES/turris-diagnostics.mo)
$(foreach mo_file,$^,install -D $(mo_file) $(INSTALL_TARGET)/$(mo_file);)
endef
$(foreach LANG, $(LANGS), $(eval $(call CASEDEF_LANG,$(LANG))))
......@@ -17,12 +17,12 @@ LANGUAGE=cs ./diagnostics.sh help
To update messages you can simply call
```bash
make messages
make update
```
Do not forget to call this command when you add new or modify existing
"gettext" strings.
Do not forget to call this command when you add new or modify existing "gettext"
strings.
Note that the translations are supposed to be edited using weblate and merged
backwards afterwards. See `turris-translations` repository for details.
backwards afterwards. See `turris-translations` repository for details.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment