diff 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
line wrap: on
line diff
--- a/GNUmakefile	Fri Sep 28 11:04:16 2012 +0000
+++ b/GNUmakefile	Fri Sep 28 11:14:47 2012 +0000
@@ -20,11 +20,32 @@
 	if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2)
 endef
 
+# List of available languages
+LANGS:=$(find xml/ -mindepth 1 -maxdepth 1 -type d -not -name '.svn' \
+		-exec basename {} \; | xargs)
+
+# process xslt and create/pass some variables into XSLT processor:
+#
+# ORIGIN	 xml source of processed document ($o in shell script)
+# NOLANGORIGIN	 html document without xml/lang prefix ($ox in shell script)
+# TRANS		 list of languages to which document is translated ($trans)
+#
+# list of all languages is used to scan thorough to determine if current
+# document has translation in each of them.
+#
 define	XSLT
 	xmllint --noout --valid $2
 	xsltproc -o $3							\
 		$(shell f=`echo $2 | sed 's,^xml/,,;s,[^/]*/,en/,'`;	\
-		[ -f xml/$$f ] && echo --stringparam ORIGIN "$$f")	\
+			ox=`echo $2 | sed 's,^xml/,,;s,[^/]*/,,'`;	\
+			o=`echo $$ox | sed 's,\.xml,\.html,'`;		\
+			trans=`for LANG in $(LANGS);			\
+			do						\
+			[ -f xml/$$LANG/$$ox ] && echo -ne "$$LANG ";	\
+			done`;						\
+		[ -f xml/$$f ] && echo --stringparam ORIGIN "$$f"; 	\
+		echo --stringparam NOLANGORIGIN "$$o";			\
+		echo --stringparam TRANS \""$$trans\"")			\
 		$(shell p="$4"; [ -n "$$p" ] &&				\
 		echo --stringparam $${p%%=*} $${p#*=})			\
 		$1 $2