comparison GNUmakefile @ 706:cd0d1f0130db

Fixed language switcher.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 04 Oct 2012 15:02:32 +0000
parents 095d1972dad9
children 81ad082bc837
comparison
equal deleted inserted replaced
705:e159f385c62b 706:cd0d1f0130db
18 | sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $(2) 18 | sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $(2)
19 19
20 if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2) 20 if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2)
21 endef 21 endef
22 22
23 # List of available languages
24 LANGS:=$(find xml/ -mindepth 1 -maxdepth 1 -type d -not -name '.svn' \
25 -exec basename {} \; | xargs)
26
27 # process xslt and create/pass some variables into XSLT processor:
28 #
29 # ORIGIN xml source of processed document ($o in shell script)
30 # NOLANGORIGIN html document without xml/lang prefix ($ox in shell script)
31 # TRANS list of languages to which document is translated ($trans)
32 #
33 # list of all languages is used to scan thorough to determine if current
34 # document has translation in each of them.
35 #
36 define XSLT 23 define XSLT
37 xmllint --noout --valid $2 24 xmllint --noout --valid $2
38 xsltproc -o $3 \ 25 xsltproc -o $3 \
39 $(shell f=`echo $2 | sed 's,^xml/,,;s,[^/]*/,en/,'`; \ 26 $(shell ff=`echo $2`; ff=$${ff#xml/}; \
40 ox=`echo $2 | sed 's,^xml/,,;s,[^/]*/,,'`; \ 27 f=$${ff#*/}; \
41 o=`echo $$ox | sed 's,\.xml,\.html,'`; \ 28 if [ "$$f" != "$$ff" ]; then \
42 trans=`for LANG in $(LANGS); \ 29 [ -f xml/en/$$f ] && echo --stringparam ORIGIN "en/$$f";\
43 do \ 30 t=; for l in $(LANGS); do \
44 [ -f xml/$$LANG/$$ox ] && echo -ne "$$LANG "; \ 31 [ -f "xml/$$l/$$f" ] && t="$$t$$l "; done; \
45 done`; \ 32 echo --stringparam TRANS "\"$$t\""; \
46 [ -f xml/$$f ] && echo --stringparam ORIGIN "$$f"; \ 33 fi) \
47 echo --stringparam NOLANGORIGIN "$$o"; \
48 echo --stringparam TRANS \""$$trans\"") \
49 $(shell p="$4"; [ -n "$$p" ] && \ 34 $(shell p="$4"; [ -n "$$p" ] && \
50 echo --stringparam $${p%%=*} $${p#*=}) \ 35 echo --stringparam $${p%%=*} $${p#*=}) \
51 $1 $2 36 $1 $2
52 endef 37 endef
53 38