changeset 3431:0568ffd29bb2

FixA: Introduced i18n to overview transformation. flys-artifacts/trunk@5091 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 21 Jul 2012 12:26:12 +0000
parents 278b5508567e
children 9c39a25aa849
files flys-artifacts/ChangeLog flys-artifacts/contrib/fixoverview2html.xsl
diffstat 2 files changed, 46 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jul 20 15:17:16 2012 +0000
+++ b/flys-artifacts/ChangeLog	Sat Jul 21 12:26:12 2012 +0000
@@ -1,3 +1,7 @@
+2012-07-21	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* contrib/fixoverview2html.xsl: Introduced i18n to transformation.
+
 2012-07-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java:
--- a/flys-artifacts/contrib/fixoverview2html.xsl	Fri Jul 20 15:17:16 2012 +0000
+++ b/flys-artifacts/contrib/fixoverview2html.xsl	Sat Jul 21 12:26:12 2012 +0000
@@ -11,6 +11,29 @@
   <xsl:param name="render-checkboxes" select="true()"/>
   <xsl:param name="callback"/>
 
+  <xsl:param name="locale">de</xsl:param>
+
+  <xsl:decimal-format name="de" decimal-separator=',' grouping-separator='.'/>
+  <xsl:decimal-format name="en" decimal-separator='.' grouping-separator=','/>
+
+  <xsl:variable name="km-pattern">
+    <xsl:choose>
+      <xsl:when test="$locale = 'de'">0,##</xsl:when>
+      <xsl:otherwise>0.##</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="i18n-event">Ereignis</xsl:variable>
+  <xsl:variable name="i18n-legend">Legende</xsl:variable>
+  <xsl:variable name="i18n-color">Farbe</xsl:variable>
+  <xsl:variable name="i18n-meaning">Bedeutung</xsl:variable>
+  <xsl:variable name="i18n-around-mnq">um MNQ</xsl:variable>
+  <xsl:variable name="i18n-around-mq">um MQ</xsl:variable>
+  <xsl:variable name="i18n-around-mhq">um MHQ</xsl:variable>
+  <xsl:variable name="i18n-above-hq5">über HQ5</xsl:variable>
+
+  <!-- TODO: Format dates according locale. -->
+
   <xsl:template match="@*" mode="min">
     <xsl:if test="position() = 1">
       <xsl:value-of select="number(.)"/>
@@ -25,7 +48,7 @@
 
   <xsl:variable name="global-min">
     <xsl:choose>
-      <xsl:when test="count(/fixings/events/event) &gt; 0">
+      <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
         <xsl:apply-templates mode="min" select="/fixings/events/event/sector/@from">
           <xsl:sort data-type="number" select="."/>
         </xsl:apply-templates>
@@ -38,7 +61,7 @@
 
   <xsl:variable name="global-max">
     <xsl:choose>
-      <xsl:when test="count(/fixings/events/event) &gt; 0">
+      <xsl:when test="count(/fixings/events/event/sector) &gt; 0">
         <xsl:apply-templates mode="max" select="/fixings/events/event/sector/@to">
           <xsl:sort data-type="number" select="."/>
         </xsl:apply-templates>
@@ -167,14 +190,14 @@
       </xsl:attribute>
       <xsl:attribute name="title">
         <xsl:text>km </xsl:text>
-        <xsl:value-of select="@from"/>
+        <xsl:value-of select="format-number(@from, $km-pattern, $locale)"/>
         <xsl:text> - </xsl:text>
-        <xsl:value-of select="@to"/>
+        <xsl:value-of select="format-number(@to, $km-pattern, $locale)"/>
         <xsl:choose>
-          <xsl:when test="@class = '0'"> / Q um MNQ</xsl:when>
-          <xsl:when test="@class = '1'"> / Q um MQ</xsl:when>
-          <xsl:when test="@class = '2'"> / Q um MHQ</xsl:when>
-          <xsl:when test="@class = '3'"> / Q über HQ5</xsl:when>
+          <xsl:when test="@class = '0'"> / Q <xsl:value-of select="$i18n-around-mnq"/></xsl:when>
+          <xsl:when test="@class = '1'"> / Q <xsl:value-of select="$i18n-around-mq"/></xsl:when>
+          <xsl:when test="@class = '2'"> / Q <xsl:value-of select="$i18n-around-mhq"/></xsl:when>
+          <xsl:when test="@class = '3'"> / Q <xsl:value-of select="$i18n-above-hq5"/></xsl:when>
         </xsl:choose>
       </xsl:attribute>
       <xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>
@@ -207,7 +230,7 @@
         <xsl:text>overflow:hidden;background:</xsl:text>
         <xsl:choose>
           <xsl:when test="(count(preceding::*) mod  2) = 0">#ada96e</xsl:when>
-          <xsl:otherwise>gray</xsl:otherwise>
+          <xsl:otherwise>silver</xsl:otherwise>
         </xsl:choose>
         <xsl:text>;width:</xsl:text>
         <xsl:call-template name="percent">
@@ -219,9 +242,9 @@
       <xsl:attribute name="title">
         <xsl:value-of select="@name"/>
         <xsl:text>: km </xsl:text>
-        <xsl:value-of select="@from"/>
+        <xsl:value-of select="format-number(@from, $km-pattern, $locale)"/>
         <xsl:text> - </xsl:text>
-        <xsl:value-of select="@to"/>
+        <xsl:value-of select="format-number(@to, $km-pattern, $locale)"/>
       </xsl:attribute>
       <nobr><xsl:value-of select="@name"/></nobr>
     </div>
@@ -242,7 +265,7 @@
           <th>&#160;</th>
         </xsl:if>
         <th><xsl:apply-templates mode="gauges" select="/fixings/gauges"/></th>
-        <th>Ereignis</th>
+        <th><xsl:value-of select="$i18n-event"/></th>
       </tr>
       <xsl:apply-templates/>
     </table>
@@ -257,36 +280,36 @@
         <xsl:apply-templates/>
         <hr/>
         <table border="1" cellspacing="0" cellpadding="0">
-          <caption>Legende</caption>
+          <caption><xsl:value-of select="$i18n-legend"/></caption>
           <tr>
-            <th>Farbe</th>
-            <th colspan="2">Bedeutung</th>
+            <th><xsl:value-of select="$i18n-color"/></th>
+            <th colspan="2"><xsl:value-of select="$i18n-meaning"/></th>
           </tr>
           <xsl:if test="count(/fixings/events/event/sector[@class = '0']) &gt; 0">
           <tr>
             <td style="background: green">&#160;</td>
-            <td>um MNQ</td>
+            <td><xsl:value-of select="$i18n-around-mnq"/></td>
             <td>Q &#8712; [0, (MNQ+MQ)/2)</td>
           </tr>
           </xsl:if>
           <xsl:if test="count(/fixings/events/event/sector[@class = '1']) &gt; 0">
           <tr>
             <td style="background: blue">&#160;</td>
-            <td>um MQ</td>
+            <td><xsl:value-of select="$i18n-around-mq"/></td>
             <td>Q &#8712; [(MNQ+MQ)/2, (MQ+MHQ)/2)</td>
           </tr>
           </xsl:if>
           <xsl:if test="count(/fixings/events/event/sector[@class = '2']) &gt; 0">
           <tr>
             <td style="background: magenta">&#160;</td>
-            <td>um MHQ</td>
+            <td><xsl:value-of select="$i18n-around-mhq"/></td>
             <td>Q &#8712; [(MQ+MHQ)/2, HQ5)</td>
           </tr>
           </xsl:if>
           <xsl:if test="count(/fixings/events/event/sector[@class = '3']) &gt; 0">
           <tr>
             <td style="background: red">&#160;</td>
-            <td>über HQ5</td>
+            <td><xsl:value-of select="$i18n-above-hq5"/></td>
             <td>Q &#8712; [HQ5, &#8734;)</td>
           </tr>
           </xsl:if>

http://dive4elements.wald.intevation.org