view xslt/menu.xslt @ 1017:9f9a427a73eb

Fixed broken links to chinese versions of some modules. The chinese version contains untranslated copies of english documentation for random_index and realip modules. The result is the appearance of 'translation to chinese' link for this modules pointing to non-existing document. This files are removed. Also, broken links are generated for the chinese version of the "flv" module, but the translation exists, although not enabled for publication. Since contents of file looks like a valid translation, it is allowed to be published.
author Vladimir Homutov <vl@nginx.com>
date Mon, 18 Nov 2013 12:48:10 +0400
parents b133b1f44765
children 2c57830e0149
line wrap: on
line source

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xsl:template match="menu/item">
      <xsl:choose>

         <xsl:when test="@href = $LINK">
            <xsl:choose>

               <xsl:when test="$YEAR and @href='/'">

                  <a href="./"> news </a> 
                  <br/>
               </xsl:when>

               <xsl:otherwise>

                  <xsl:value-of select=" normalize-space(text())"/>
                  <br/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:when>

         <xsl:otherwise>
            <xsl:choose>

               <xsl:when test="$TRANS and @switchlang">
                  <xsl:choose>

                     <xsl:when test="contains($TRANS, @switchlang)">

                        <a>

                           <xsl:attribute name="href">

                              <xsl:value-of select=" concat($ROOT, '/', @switchlang, '/',                         substring-after($LINK, concat('/', $LANG, '/')))"/>
                           </xsl:attribute>

                           <xsl:value-of select=" normalize-space(text())"/>

                        </a>
                     </xsl:when>

                     <xsl:otherwise>

                        <a class="notrans">
                           <xsl:value-of select=" normalize-space(text())"/>
                        </a>
                     </xsl:otherwise>
                  </xsl:choose>
               </xsl:when>

               <xsl:otherwise>

                  <a>

                     <xsl:attribute name="href">
                        <xsl:choose>

                           <xsl:when test="starts-with(@href, $DIRNAME)">
                              <xsl:choose>

                                 <xsl:when test="substring-after(@href, $DIRNAME) = ''">
                        ./</xsl:when>

                                 <xsl:otherwise>

                                    <xsl:value-of select=" substring-after(@href, $DIRNAME)"/>
                                 </xsl:otherwise>
                              </xsl:choose>
                           </xsl:when>

                           <xsl:otherwise>

                              <xsl:value-of select=" concat($ROOT, @href)"/>
                           </xsl:otherwise>
                        </xsl:choose>
                     </xsl:attribute>

                     <xsl:value-of select=" normalize-space(text())"/>

                  </a>

                  <xsl:if test="@lang">
                     <xsl:text> [</xsl:text>
                     <xsl:value-of select="@lang"/>
                     <xsl:text>]</xsl:text>
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>

            <br/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <xsl:template match="menu/item[@year]">

      <xsl:if test="$YEAR or $LINK='/'">
         <xsl:choose>

            <xsl:when test="$YEAR=@year">

               <xsl:value-of select="@year"/> 
               <br/>
            </xsl:when>

            <xsl:otherwise>

               <xsl:if test="@href"> 
                  <a href="{@href}">
                     <xsl:value-of select="@year"/>
                  </a>
               </xsl:if>

               <br/>
            </xsl:otherwise>
         </xsl:choose>
      </xsl:if>
   </xsl:template>

   <xsl:template match="menu/item[starts-with(@href, 'http://') or starts-with(@href, 'https://')]">

      <a href="{@href}">
         <xsl:value-of select=" normalize-space(text())"/>
      </a>

      <xsl:if test="@lang">
         <xsl:text> [</xsl:text>
         <xsl:value-of select="@lang"/>
         <xsl:text>]</xsl:text>
      </xsl:if>

      <br/>
   </xsl:template>

   <xsl:template match="menu/item[not(@href) and not(@year)]">

      <xsl:value-of select=" normalize-space(text())"/> 
      <br/>
   </xsl:template>

</xsl:stylesheet>