forked from project-ethea/Ethea-i18n
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (65 loc) · 2.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Path to Wesnoth's wmlxgettext tool (should be the rewritten version from
# 1.13.x and later).
WMLXGETTEXT ?= wmlxgettext
# Path to pocheck
POCHECK ?= ./pocheck
# Path to the add-ons root. It should contain directories matching the names
# of the add-on translation directories found in this repository, so that the
# WML tools can read Lua and WML files from them.
ADDONS_PREFIX ?= ..
TRANSLATION_THRESHOLD = 80
SOURCES = \
Invasion_from_the_Unknown \
After_the_Storm \
Naia
MANIFESTS := $(foreach dir,$(SOURCES),$(dir)/$(dir).manifest)
POTS := $(foreach dir,$(SOURCES),$(dir)/wesnoth-$(dir).pot)
MOS := $(foreach dir,$(SOURCES),$(patsubst %.po,%.mo,$(wildcard $(dir)/*.po)))
all: po-update
pot-update: $(MANIFESTS) $(POTS)
%.manifest: FORCE
@( cd $(ADDONS_PREFIX)/`basename $*` && git describe --long ) > $@
%.pot: FORCE
@echo " POT `basename $@`"
@$(WMLXGETTEXT) --recursive --warnall --directory=$(ADDONS_PREFIX)/`dirname $*` --domain `basename $*` --package-version `cat $(ADDONS_PREFIX)/$$(dirname $*)/dist/VERSION` -o $@
@msgfmt --statistics -o /dev/null $@ 2>&1 | sed -E 's/^.*\s([0-9]+)\s.*$$/ \1 strings/'
po-update: $(MOS)
%.po: FORCE
@echo " UPD `basename $@` [wesnoth-`dirname $@`]"
@msgmerge -q $@ $(dir $@)wesnoth-`dirname $@`.pot > [email protected]
@mv -f [email protected] $@
%.mo: %.po
@echo " FMT `basename $@` [wesnoth-`dirname $@`]"
@msgfmt --statistics -o $@ $*.po
install: po-update
@for s in $(SOURCES); do for mo in $$s/*.mo; do \
locale="`basename -s .mo $$mo`"; \
target_dir="$(ADDONS_PREFIX)/$$s/translations/$$locale/LC_MESSAGES"; \
target_mo="$$target_dir/wesnoth-$$s.mo"; \
mkdir -p "$$target_dir"; \
echo " INSTALL $$target_mo"; \
perc="`$(POCHECK) $$s/$$locale.po`"; \
if test $$? && test $$perc -lt $(TRANSLATION_THRESHOLD); then \
echo "*** Translation below threshold ($$perc%), removing from target..."; \
rm -f "$$target_mo"; \
continue; \
fi; \
cp -f "$$mo" "$$target_mo"; \
pbl="$$s/$$locale.pbltrans"; \
target_pbl="$(ADDONS_PREFIX)/$$s/translations/$$locale.pbltrans"; \
if test -e "$$pbl"; then \
echo " INSTALL $$target_pbl"; \
cp -f "$$pbl" "$$target_pbl"; \
fi; \
done; done
clean: clean-mo
clean-pot:
find -name '*.pot' -or -name '*.manifest' -type f -print0 | xargs -0 rm -f
clean-mo:
find \( \
-name '*.new' -o \
-name '*.tmp' -o \
-name '*.mo' \
\) -type f -print0 | xargs -0 rm -f
.PHONY: FORCE
FORCE: