-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
po.mk
executable file
·54 lines (43 loc) · 1.17 KB
/
po.mk
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
#!/usr/bin/make -f
DOMAIN = oomox
PODIR = po
SOURCES = $(wildcard oomox_gui/*.py) $(wildcard plugins/*/oomox_plugin.py)
LOCALEDIR = ./locale
XGETTEXT ?= xgettext --package-name=$(DOMAIN) \
--foreign-user --keyword=translate --keyword='translate_many:1,2' \
--language=python --add-comments --sort-output --from-code=UTF-8
MSGINIT ?= msginit
MSGMERGE ?= msgmerge
MSGFMT ?= msgfmt
RM ?= rm -f
INSTALL ?= install
MKDIR_P ?= mkdir -p
POTFILE = $(PODIR)/$(DOMAIN).pot
ALL_PO = $(wildcard $(PODIR)/*.po)
ALL_MO = $(ALL_PO:.po=.mo)
all: install
update-pot: $(POTFILE)
update-po: $(ALL_PO)
$(POTFILE): $(SOURCES)
test -d $(PODIR) || $(MKDIR_P) $(PODIR)
$(XGETTEXT) -o $@ $^
$(PODIR)/%.po: $(POTFILE)
if test -f $@; then \
$(MSGMERGE) -U $@ $(POTFILE); \
else \
$(MSGINIT) -o $@ -i $(POTFILE); \
fi
$(PODIR)/%.mo: $(PODIR)/%.po
$(MSGFMT) -o $@ $^
install: $(ALL_MO)
for f in $^; do \
l="$$(basename "$$f" .mo)"; \
d="$(LOCALEDIR)/$$l/LC_MESSAGES"; \
$(MKDIR_P) "$$d" || exit; \
$(INSTALL) -m 644 "$$f" "$$d/$(DOMAIN).mo"; \
done
check: $(ALL_PO)
$(MSGFMT) --check --check-accelerators=_ --statistics $^
clean:
$(RM) $(POTFILE)
$(RM) $(PODIR)/*.mo