You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by he...@apache.org on 2005/09/18 23:09:07 UTC

svn commit: r289975 - in /cocoon/branches/BRANCH_2_1_X/src/webapp: samples/sitemap.xmap stylesheets/system/calendar2html.xslt

Author: hepabolu
Date: Sun Sep 18 14:09:00 2005
New Revision: 289975

URL: http://svn.apache.org/viewcvs?rev=289975&view=rev
Log:
Updated CalendarGenerator sample to show off localization

Modified:
    cocoon/branches/BRANCH_2_1_X/src/webapp/samples/sitemap.xmap
    cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/calendar2html.xslt

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/samples/sitemap.xmap?rev=289975&r1=289974&r2=289975&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/samples/sitemap.xmap (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/samples/sitemap.xmap Sun Sep 18 14:09:00 2005
@@ -175,10 +175,16 @@
       <map:parameter name="year" value="1998"/>
       -->
       <map:parameter name="dateFormat" value="EEEE, MMMM d yyyy"/>
-      <map:parameter name="lang" value="en"/>
-      <map:parameter name="country" value="US"/>
+      <map:parameter name="lang" value="{request-param:lang}"/>
+      <map:parameter name="country" value="{request-param:country}"/>
     </map:generate>
     <map:transform src="context://stylesheets/system/calendar2html.xslt"/>
+	<!-- to localize the column headers, remove the comments below -->
+	<!--
+    <map:transform type="i18n">
+       <map:parameter name="locale" value="{request-param:lang}-{request-param:country}"/>
+    </map:transform>
+  	-->
     <map:serialize/>
    </map:match>
 

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/calendar2html.xslt
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/calendar2html.xslt?rev=289975&r1=289974&r2=289975&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/calendar2html.xslt (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/calendar2html.xslt Sun Sep 18 14:09:00 2005
@@ -15,10 +15,11 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: calendar2html.xslt,v 1.3 2004/04/09 14:31:48 ugo Exp $ -->
+<!-- CVS $Id$ -->
 
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
                 xmlns:calendar="http://apache.org/cocoon/calendar/1.0">
 
   <xsl:template match="/">
@@ -60,6 +61,10 @@
   padding-bottom: 2px;
 }
 
+.calendar .weekend {
+  background-color: #c0c0c0;
+}
+
 .calendar .daytitle {
   position: relative;
   left: 0;
@@ -91,6 +96,22 @@
         </style>
       </head>
       <body>
+        <p>
+        This sample shows a calendar that can be filled with events. The calendar is localized, try one of the
+        following examples:
+        </p>
+        <p>
+        <a href="cal?lang=en&amp;country=US">US English</a><br/>
+        <a href="cal?lang=en&amp;country=UK">UK English</a><br/>
+        <a href="cal?lang=nl">Dutch</a><br/>
+        <a href="cal?lang=fr">French</a><br/>
+        <a href="cal?lang=el">Greek</a>
+        </p>
+        <p>Note: the column headers and date format are not localized, you can do that by simply inserting the appropriate
+          i18n tags and transformer. Check the sample sources (sitemap and XSLT style sheet) and uncomment
+          the lines.
+        </p>
+        <hr/>
         <xsl:apply-templates/>
       </body>
     </html>
@@ -104,13 +125,21 @@
         </caption>
         <thead>
           <tr>
-            <th>Sunday</th>
-            <th>Monday</th>
-            <th>Tuesday</th>
-            <th>Wednesday</th>
-            <th>Thursday</th>
-            <th>Friday</th>
-            <th>Saturday</th>
+            <xsl:for-each select="calendar:week[2]/calendar:day">
+              <th>
+                <xsl:if test="@weekday = 'Saturday' or @weekday='Sunday'">
+                    <xsl:attribute name="class">weekend</xsl:attribute>
+                </xsl:if>
+                <!-- uncomment the lines below for i18n localization -->
+                <!-- Note that you also need to provide the appropriate message files
+                <i18n:text>
+                -->
+                <xsl:value-of select="@weekday"/>
+                <!--
+                </i18n:text>
+                -->
+              </th>
+            </xsl:for-each>
           </tr>
         </thead>
         <tbody>
@@ -119,7 +148,7 @@
       </table>
     </div>
   </xsl:template>
-  
+
   <xsl:template match="calendar:week">
     <tr>
       <xsl:if test="position() = 1">
@@ -146,6 +175,9 @@
       </xsl:if>
       <xsl:for-each select="calendar:day">
         <td>
+          <xsl:if test="@weekday = 'Saturday' or @weekday = 'Sunday'">
+            <xsl:attribute name="class">weekend</xsl:attribute>
+          </xsl:if>
           <div class="daytitle"><xsl:value-of select="@number"/></div>
           <p><xsl:value-of select="@date"/></p>
         </td>
@@ -175,4 +207,4 @@
     </tr>
   </xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>