summaryrefslogtreecommitdiff
blob: e23e220e48afe19c0d931a271ccc7dfcf40695cc (plain)
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
# (c) 2010 gentoo-doc-ru team
# # https://projects.gentoo.ru/projects/gentoo-doc-ru

include Makefile.config

XML := $(foreach dir, $(BASEDIR), $(wildcard $(dir)/*.xml))

xml: $(addprefix xml-, $(LANGS))
$(addprefix xml-, $(LANGS)): $(addprefix po-, $(LANGS))

po: $(addprefix po-, $(LANGS))
$(addprefix po-, $(LANGS)): pot

pot: $(addprefix $(POTDIR)/, $(addsuffix .pot, $(notdir $(XML))))

define xml-lang-template
lang:=$(subst xml-,,$(1))
$(1): $(addprefix $(XML_OUT)/$(lang)/security/, $(notdir $(XML)) )

$(XML_OUT)/$(lang)/security/%: $(POTDIR)/$(lang)/%.po
	@if [ ! -d $(XML_OUT)/$(lang)/ ]; then \
		mkdir -p $(XML_OUT)/$(lang)/security/; \
	fi;
	$(XML2PO) -p $$? $(BASEDIR)/$$(@F) > $$@
endef

$(foreach lang, $(LANGS), $(eval $(call xml-lang-template, xml-$(lang))))

define po-lang-template
lang:= $(subst po-,,$(1))
$(1): $(addprefix $(POTDIR)/$(lang)/, $(addsuffix .po, $(notdir $(XML))))

$(POTDIR)/$(lang)/%.po: $(POTDIR)/%.pot
	@if [ ! -d $(POTDIR)/$(lang)/ ]; then \
		mkdir -p $(POTDIR)/$(lang)/; \
	fi;
	if [ -f $$@ ]; then \
		msgmerge --quiet --backup=none -U $$@ $$?; \
		msgattrib --no-obsolete $$@ --output $$@; \
		touch $$@; \
	else \
		msginit -l $(lang) --no-translator -i $$? -o $$@; \
	fi;
endef

$(foreach lang, $(LANGS), $(eval $(call po-lang-template, po-$(lang))))

$(POTDIR)/%.pot: $(BASEDIR)/%
	@if [ ! -d $(POTDIR) ]; then \
		mkdir -p $(POTDIR); \
	fi;
	$(XML2PO) -o $@ $?

help:
	@echo ""
	@echo "    Supported targets: pot po-<LANG> xml xml-<LANG>"
	@echo "    Substitude LANG with yours. Don't forget edit Makefile.config"
	@echo ""