Mercurial > hg > nginx-site
diff xsls/menu.xsls @ 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 | 6c0532e6982f |
children | cd0d1f0130db |
line wrap: on
line diff
--- a/xsls/menu.xsls +++ b/xsls/menu.xsls @@ -21,25 +21,56 @@ X:template = "menu/item" { } } else { - <a> - X:attribute "href" { + + <!-- + -- If a menu item has the switchlang attribute, then it will point + -- to the same document in the specified language. + -- The document will be taken from $NOLANGORIGIN variable. + --> + X:if "@switchlang != ''" { - X:if "starts-with(@href, $DIRNAME)" { - X:if "substring-after(@href, $DIRNAME) = ''" { - ./ - - } else { - !{ substring-after(@href, $DIRNAME) } - } + <!-- + -- Check if list of available translations ($TRANS) contains + -- the language we are going to generate link to. + -- If yes - generate link, otherwise just name the language. + --> + X:if "contains($TRANS, @switchlang)" { + <a> + X:attribute "href" { + X:if "$ROOT != '' " { + !{ concat($ROOT, '/', @switchlang, '/', $NOLANGORIGIN) } + } else { + !{ concat(@switchlang, '/', $NOLANGORIGIN) } + } + } + !{ normalize-space(text()) } + </a> } else { - !{ concat($ROOT, @href) } + <a class="notrans"> !{ normalize-space(text()) } </a> } + } else { + + <a> + X:attribute "href" { + + X:if "starts-with(@href, $DIRNAME)" { + X:if "substring-after(@href, $DIRNAME) = ''" { + ./ + } else { + !{ substring-after(@href, $DIRNAME) } + } + + } else { + + !{ concat($ROOT, @href) } + } + } + !{ normalize-space(text()) } + </a> + + X:if "@lang" { X:text { [} !{@lang} X:text {]}} } - !{ normalize-space(text()) } - </a> - - X:if "@lang" { X:text { [} !{@lang} X:text {]}} <br/> }