Anonymous avatar Anonymous committed 0327967

Adding sample for proper I18NInterceptor usage

Issue Number: XW-478

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2876 573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (10)

webapps/showcase/src/java/com/opensymphony/webwork/showcase/i18n/ChangeRequestLocaleAction.java

+package com.opensymphony.webwork.showcase.i18n;
+
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * <code>ChangeRequestLocaleAction</code>
+ *
+ * @author <a href="mailto:hermanns@aixcept.de">Rainer Hermanns</a>
+ * @version $Id: $
+ */
+public class ChangeRequestLocaleAction extends ActionSupport {
+}

webapps/showcase/src/java/com/opensymphony/webwork/showcase/i18n/ChangeRequestLocaleAction.properties

+label.add=Add
+label.cancel=Cancel
+label.delete=Delete
+label.edit=Edit
+label.save=Save
+label.search=Search

webapps/showcase/src/java/com/opensymphony/webwork/showcase/i18n/ChangeRequestLocaleAction_de.properties

+label.add=Hinzuf\u00fcgen
+label.cancel=Abbrechen
+label.delete=L\u00f6schen
+label.edit=Bearbeiten
+label.save=Speichern
+label.search=Suchen

webapps/showcase/src/java/com/opensymphony/webwork/showcase/i18n/ChangeRequestLocaleAction_en.properties

+label.add=Add
+label.cancel=Cancel
+label.delete=Delete
+label.edit=Edit
+label.save=Save
+label.search=Search

webapps/showcase/src/java/com/opensymphony/webwork/showcase/i18n/ChangeRequestLocaleAction_fr.properties

+label.add=Ajouter
+label.cancel=Annuler
+label.delete=Supprimer
+label.edit=Editer
+label.save=Sauvegarder
+label.search=Rechercher

webapps/showcase/src/webapp/WEB-INF/classes/xwork-i18n.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xwork PUBLIC
+	"-//OpenSymphony Group//XWork 1.1.1//EN"
+	"http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
+
+<xwork>
+	<package name="i18n" namespace="/i18n" extends="webwork-default">
+        <action name="changeLocale" class="com.opensymphony.webwork.showcase.i18n.ChangeRequestLocaleAction">
+            <interceptor-ref name="i18n"/>
+            <result name="success">index.jsp</result>
+        </action>
+	</package>
+</xwork>
+
+

webapps/showcase/src/webapp/WEB-INF/classes/xwork.xml

 
 	<include file="xwork-wizard.xml" />
 	
-	<include file="xwork-sessionInvalidation.xml" />
+	<!--include file="xwork-sessionInvalidation.xml" /-->
 	
 	<include file="xwork-flash.xml" />
 	
 	<include file="xwork-sitemesh.xml" />
 
+    <include file="xwork-i18n.xml" />
+
     <package name="default" extends="webwork-default">
         <interceptors>
             <interceptor-stack name="crudStack">

webapps/showcase/src/webapp/WEB-INF/decorators/main.jsp

                     <li><a href="<ww:url action="index" namespace="/wizard" />">Wizard</a></li>
                     <li><a href="<ww:url action="start" namespace="/sessionInvalidation"/>">Session Invalidation</a></li>
                     <li><a href="<ww:url action="start" namespace="/flash"/>">Flash</a></li>
+                    <li><a href="<ww:url action="changeLocale" namespace="/i18n"/>">I18N</a></li>
                     <li class="last"><a href="<ww:url value="/help.jsp"/>">Help</a></li>
                 </ul>
             </div>

webapps/showcase/src/webapp/i18n/index.jsp

+<%@ taglib prefix="ww" uri="/webwork" %>
+<html>
+<head>
+    <title>Acme Corp</title>
+</head>
+
+<body>
+<p>
+    <h4>Using URL Tag</h4>
+    <ww:url id="changeLanguageURLen" action="changeLocale" includeParams="none">
+        <ww:param name="request_locale">en</ww:param>
+    </ww:url>
+
+    <ww:url id="changeLanguageURLde" action="changeLocale" includeParams="none">
+        <ww:param name="request_locale">de</ww:param>
+    </ww:url>
+
+    <ww:url id="changeLanguageURLfr" action="changeLocale" includeParams="none">
+        <ww:param name="request_locale">fr</ww:param>
+    </ww:url>
+
+    <ww:a href="%{changeLanguageURLen}">English (en)</ww:a>
+    <ww:a href="%{changeLanguageURLde}">German (de)</ww:a>
+    <ww:a href="%{changeLanguageURLfr}">French (fr)</ww:a>
+</p>
+<p>
+    <h4>Using href with request_locale parameter</h4>
+
+    <a href="changeLocale.action?request_locale=en">English (en)</a>
+    <a href="changeLocale.action?request_locale=de">German (de)</a>
+    <a href="changeLocale.action?request_locale=fr">French (fr)</a>
+</p>
+
+<p>
+    <h4></h4>
+
+    <ww:url id="changeLanguageURLenParam" action="changeLocale?request_locale=en"  includeParams="none"/>
+    <ww:url id="changeLanguageURLdeParam" action="changeLocale?request_locale=de"  includeParams="none"/>
+    <ww:url id="changeLanguageURLfrParam" action="changeLocale?request_locale=fr"  includeParams="none"/>
+
+    <ww:a href="%{changeLanguageURLenParam}">English (en)</ww:a>
+    <ww:a href="%{changeLanguageURLdeParam}">German (de)</ww:a>
+    <ww:a href="%{changeLanguageURLfrParam}">French (fr)</ww:a>
+</p>
+
+<hr width="90%" />
+<h4>Internationalized Labels for Locale <ww:property value="%{locale}"/></h4>
+<table>
+    <tr>
+        <th>i18n key</th>
+        <th>value</th>
+    </tr>
+    <tr>
+        <td><strong>label.add</strong></td>
+        <td><ww:property value="%{getText('label.add')}" /></td>
+    </tr>
+    <tr>
+        <td><strong>label.cancel</strong></td>
+        <td><ww:property value="%{getText('label.cancel')}" /></td>
+    </tr>
+    <tr>
+        <td><strong>label.delete</strong></td>
+        <td><ww:property value="%{getText('label.delete')}" /></td>
+    </tr>
+    <tr>
+        <td><strong>label.edit</strong></td>
+        <td><ww:property value="%{getText('label.edit')}" /></td>
+    </tr>
+    <tr>
+        <td><strong>label.save</strong></td>
+        <td><ww:property value="%{getText('label.save')}" /></td>
+    </tr>
+    <tr>
+        <td><strong>label.search</strong></td>
+        <td><ww:property value="%{getText('label.search')}" /></td>
+    </tr>
+</table>
+</body>
+</html>

webapps/showcase/src/webapp/showcase.jsp

         
         <!--  flash  -->
         <li><ww:url id="url" action="start" namespace="/flash"/><ww:a href="%{url}">Flash Example</ww:a></li>
-        
+
+        <!--  i18n  -->
+        <li><ww:url id="url" action="changeLocale" namespace="/i18n"/><ww:a href="%{url}">I18N Example</ww:a></li>
+
     </ul>
 </p>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.