Mercurial > hg > nginx-site
comparison GNUmakefile @ 693:095d1972dad9
Added ability to switch languages without context change.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Fri, 28 Sep 2012 11:14:47 +0000 |
parents | b2db67ca29cc |
children | cd0d1f0130db |
comparison
equal
deleted
inserted
replaced
692:31ba6a104186 | 693:095d1972dad9 |
---|---|
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 # | |
23 define XSLT | 36 define XSLT |
24 xmllint --noout --valid $2 | 37 xmllint --noout --valid $2 |
25 xsltproc -o $3 \ | 38 xsltproc -o $3 \ |
26 $(shell f=`echo $2 | sed 's,^xml/,,;s,[^/]*/,en/,'`; \ | 39 $(shell f=`echo $2 | sed 's,^xml/,,;s,[^/]*/,en/,'`; \ |
27 [ -f xml/$$f ] && echo --stringparam ORIGIN "$$f") \ | 40 ox=`echo $2 | sed 's,^xml/,,;s,[^/]*/,,'`; \ |
41 o=`echo $$ox | sed 's,\.xml,\.html,'`; \ | |
42 trans=`for LANG in $(LANGS); \ | |
43 do \ | |
44 [ -f xml/$$LANG/$$ox ] && echo -ne "$$LANG "; \ | |
45 done`; \ | |
46 [ -f xml/$$f ] && echo --stringparam ORIGIN "$$f"; \ | |
47 echo --stringparam NOLANGORIGIN "$$o"; \ | |
48 echo --stringparam TRANS \""$$trans\"") \ | |
28 $(shell p="$4"; [ -n "$$p" ] && \ | 49 $(shell p="$4"; [ -n "$$p" ] && \ |
29 echo --stringparam $${p%%=*} $${p#*=}) \ | 50 echo --stringparam $${p%%=*} $${p#*=}) \ |
30 $1 $2 | 51 $1 $2 |
31 endef | 52 endef |
32 | 53 |