[seam-commits] Seam SVN: r13282 - modules/international/trunk/docs/reference/src/main/docbook/en-US.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Jun 20 15:35:38 EDT 2010


Author: kenfinni
Date: 2010-06-20 15:35:38 -0400 (Sun, 20 Jun 2010)
New Revision: 13282

Modified:
   modules/international/trunk/docs/reference/src/main/docbook/en-US/locales.xml
   modules/international/trunk/docs/reference/src/main/docbook/en-US/messages.xml
   modules/international/trunk/docs/reference/src/main/docbook/en-US/timezones.xml
Log:
Update i18n reference guide

Modified: modules/international/trunk/docs/reference/src/main/docbook/en-US/locales.xml
===================================================================
--- modules/international/trunk/docs/reference/src/main/docbook/en-US/locales.xml	2010-06-20 01:57:33 UTC (rev 13281)
+++ modules/international/trunk/docs/reference/src/main/docbook/en-US/locales.xml	2010-06-20 19:35:38 UTC (rev 13282)
@@ -1,6 +1,109 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
-<chapter id="locales">
+<chapter id="international.locales">
 	<title>Locales</title>
+	<section id="defaultlc">
+		<title>Default Locale</title>
+		<para>
+			In a similar fashion to TimeZones we have an application <literal>Locale</literal> retrieved by
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+java.util.Locale lc;]]></programlisting>
+		<para>
+			accessible via EL with "defaultLocale".
+		</para>
+		<para>
+			By default the <literal>Locale</literal> will be set to the JVM default, unless you override the <literal>DefaultLocaleProducer</literal> Bean through XML Config.
+			Here are a few examples of XML that can be used to define the various types of Locales that are available ...
+		</para>
+		<para>
+			This will set the default language to be French.
+		</para>
+<programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:s="urn:java:seam:core" 
+   xmlns:lc="urn:java:org.jboss.seam.international.locale"
+   xsi:schemaLocation="
+      http://java.sun.com/xml/ns/javaee 
+      http://docs.jboss.org/cdi/beans_1_0.xsd">
+
+    <lc:DefaultLocaleProducer>
+        <s:specializes/>
+        <lc:defaultLocaleKey>fr</lc:defaultLocaleKey>
+    </lc:DefaultLocaleProducer>
+</beans>]]></programlisting>
+		<para>
+			This will set the default language to be English with the country of US.
+		</para>
+<programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:s="urn:java:seam:core" 
+   xmlns:lc="urn:java:org.jboss.seam.international.locale"
+   xsi:schemaLocation="
+      http://java.sun.com/xml/ns/javaee 
+      http://docs.jboss.org/cdi/beans_1_0.xsd">
+
+    <lc:DefaultLocaleProducer>
+        <s:specializes/>
+        <lc:defaultLocaleKey>en_US</lc:defaultLocaleKey>
+    </lc:DefaultLocaleProducer>
+</beans>]]></programlisting>
+		<para>
+			As you can see from the previous examples, you can define the <literal>Locale</literal> with lang_country_variant.  It's important to note that the first two parts of the locale definition
+			are not expected to be greater than 2 characters otherwise an error will be produced and it will default to the JVM <literal>Locale</literal>.
+		</para>
+	</section>
+	<section id="userlc">
+		<title>User Locale</title>
+		<para>
+			The Locale associated with the User Session can be retrieved by
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+ at UserLocale
+java.util.Locale locale;]]></programlisting>
+		<para>
+			which is EL accessible via "userLocale".
+		</para>
+		<para>
+			By default the <literal>Locale</literal> will be the same as that of the application when the User Session is initially created.  However, changing the User's <literal>Locale</literal> is a simple
+			matter of firing an event to update it.  An example would be
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+ at Changed
+Event<java.util.Locale> localeEvent;
+ 
+public void setUserLocale()
+{
+     Locale canada = Locale.CANADA;
+     localeEvent.fire(canada);
+}]]></programlisting>
+	</section>
+	<section id="availlc">
+		<title>Available Locales</title>
+		<para>
+			We've also provided a list of available Locales that can be accessed via
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+List<java.util.Locale> locales;]]></programlisting>
+		<para>
+			The locales that will be returned with this can be defined with XML configuration of the <literal>AvailableLocales</literal> Bean such as
+		</para>
+<programlisting role="XML"><![CDATA[<beans xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xmlns:s="urn:java:seam:core" 
+   xmlns:lc="urn:java:org.jboss.seam.international.locale"
+   xsi:schemaLocation="
+      http://java.sun.com/xml/ns/javaee 
+      http://docs.jboss.org/cdi/beans_1_0.xsd">
+
+    <lc:AvailableLocales>
+        <s:specializes/>
+        <lc:supportedLocaleKeys>
+            <s:value>en</s:value>
+            <s:value>fr</s:value>
+        </lc:supportedLocaleKeys>
+    </lc:AvailableLocales>
+</beans>]]></programlisting>
+	</section>
 </chapter>
\ No newline at end of file

Modified: modules/international/trunk/docs/reference/src/main/docbook/en-US/messages.xml
===================================================================
--- modules/international/trunk/docs/reference/src/main/docbook/en-US/messages.xml	2010-06-20 01:57:33 UTC (rev 13281)
+++ modules/international/trunk/docs/reference/src/main/docbook/en-US/messages.xml	2010-06-20 19:35:38 UTC (rev 13282)
@@ -1,6 +1,53 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
    "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
 <chapter id="international.messages">
 	<title>Messages</title>
+	<para>
+		There are currently two ways to create a message within the module.
+	</para>
+	<para>
+		The first would mostly be used when you don't want to add the generated message directly to the UI, but want to log it out, or store it somewhere else
+	</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+MessageFactory factory;
+ 
+public String getMessage()
+{
+     MessageBuilder builder = factory.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");#
+     return builder.build().getText();
+}]]></programlisting>
+	<para>
+		The second is to add the message to a list that will be returned to the UI for display.
+	</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+Messages messages;
+ 
+public void setMessage()
+{
+     messages.info("There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");
+}]]></programlisting>
+	<para>
+		Either of these methods supports the four message levels which are info, warning, error and fatal.
+	</para>
+	<para>
+		Both the MessageFactory and Messages classes support four ways in which to create a Message:</para>
+	<itemizedlist>
+		<listitem>Directly adding the message</listitem>
+		<listitem>Directly adding the message and replacing parameters</listitem>
+		<listitem>Retrieving the message from a bundle</listitem>
+		<listitem>Retrieving the message from a bundle and replacing parameters</listitem>
+	</itemizedlist>
+	<para>
+		Examples for each of these are:</para>
+	<itemizedlist>
+		<listitem><programlisting role="JAVA"><![CDATA[messages.info("Simple Text");]]></programlisting></listitem>
+		<listitem><programlisting role="JAVA"><![CDATA[messages.info("Simple Text with {0} parameter", 1);]]></programlisting></listitem>
+		<listitem><programlisting role="JAVA"><![CDATA[messages.info(new BundleKey("org.jboss.international.seam.test.TestBundle", "key1"));]]></programlisting></listitem>
+		<listitem><programlisting role="JAVA"><![CDATA[messages.info(new BundleKey("org.jboss.international.seam.test.TestBundle", "key2"), 1);]]></programlisting></listitem>
+	</itemizedlist>
+	<para>
+		The above examples assume that there is a properties file existing at <literal>org.jboss.international.seam.test.TestBundle.properties</literal> with <literal>key1</literal> being a simple text string
+		and <literal>key2</literal> including a single parameter.
+	</para>
 </chapter>
\ No newline at end of file

Modified: modules/international/trunk/docs/reference/src/main/docbook/en-US/timezones.xml
===================================================================
--- modules/international/trunk/docs/reference/src/main/docbook/en-US/timezones.xml	2010-06-20 01:57:33 UTC (rev 13281)
+++ modules/international/trunk/docs/reference/src/main/docbook/en-US/timezones.xml	2010-06-20 19:35:38 UTC (rev 13282)
@@ -11,9 +11,10 @@
 		<title>Default TimeZone</title>
 		<para>
 			Starting at the application level the module provides a <literal>DateTimeZone</literal> that can be retrieved with
-<programlisting>
- at Inject
-DateTimeZone applicationTimeZone;</programlisting>
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+DateTimeZone applicationTimeZone;]]></programlisting>
+		<para>
 			It can also be accessed through EL by the name "defaultTimeZone"!
 		</para>
 		<para>
@@ -38,34 +39,33 @@
 		<title>User TimeZone</title>
 		<para>
 			We also have a <literal>DateTimeZone</literal> that is scoped to the User Session which can be retrieved with
-<programlisting>
- at Inject
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
 @UserTimeZone
-DateTimeZone userTimeZone;</programlisting>
+DateTimeZone userTimeZone;]]></programlisting>
+		<para>
 			It can also be accessed through EL using "userTimeZone".
 		</para>
 		<para>
 			By default the <literal>TimeZone</literal> will be the same as the application when the User Session is initialised.  However, changing
 			the User's <literal>TimeZone</literal> is a simple matter of firing an event to update it.  An example would be
-<programlisting>
- at Inject
+		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
 @Changed
-Event&lt;DateTimeZone&gt; tzEvent;
+Event<DateTimeZone> tzEvent;
  
 public void setUserTimeZone()
 {
      DateTimeZone tijuana = DateTimeZone.forID("America/Tijuana");
      tzEvent.fire(tijuana);
-}</programlisting>
-		</para>
+}]]></programlisting>
 	</section>
 	<section id="availtz">
 		<title>Available TimeZones</title>
 		<para>
 			We've also provided a list of available TimeZones that can be accessed via
-<programlisting>
- at Inject
-List&lt;DateTimeZone&gt; timeZones;</programlisting>
 		</para>
+<programlisting role="JAVA"><![CDATA[@Inject
+List<DateTimeZone> timeZones;]]></programlisting>
 	</section>
 </chapter>
\ No newline at end of file



More information about the seam-commits mailing list