avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject cvs commit: avalon-excalibur/i18n/src/xdocs index.xml
Date Fri, 21 Feb 2003 21:07:00 GMT
leosimons    2003/02/21 13:07:00

  Modified:    i18n/src/xdocs index.xml
  Log:
  some minimal docs. Doubt anyone needs more :D
  
  Revision  Changes    Path
  1.5       +55 -1     avalon-excalibur/i18n/src/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/i18n/src/xdocs/index.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- index.xml	7 Aug 2002 05:44:03 -0000	1.4
  +++ index.xml	21 Feb 2003 21:07:00 -0000	1.5
  @@ -3,7 +3,7 @@
   <document>
       <properties>
           <title>Excalibur Internationalization - Overview</title>
  -        <author email="peter at apache.org">Peter Donald</author>
  +        <author email="dev@avalon.apache.org">Avalon Documentation Team</author>
       </properties>
       <body>
           <section name="Introduction">
  @@ -13,6 +13,60 @@
                 Excalibur includes a method of managing resources, and
                 an interface for specifying the resource.  Support for
                 XML resource bundles are still under development.
  +            </p>
  +        </section>
  +        <section name="usage">
  +            <p>
  +                Using the i18n code is really straightforward; a good
  +                example of its use is Avalon-Phoenix, which is completely
  +                internationalized. The basic setup is something like
  +                (lines wrapped for readability):
  +            </p>
  +
  +            <pre>
  +// in a file called src/java/MyClass.java
  +
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
  +
  +public class MyClass implements MyInterface
  +{
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( MyClass.class );
  +
  +    public void doStuff( Object myArg ) throws Exception
  +    {
  +        // ...
  +        final String stupidArgumentIdentifier = myArg.toString();
  +        // ...
  +        final String message =
  +                REZ.getString( "myclass.error.dostuff.bad-argument",
  +                        stupidArgumentIdentifier );
  +        m_logger.error( message );
  +        throw new SomeException( message, myArg );
  +    }
  +
  +}
  +
  +# in a file called src/java/Resources.properties
  +myclass.error.dostuff.bad-argument=the argument passed to the \
  +doStuff method is invalid; it is {0}, which is plain silly!
  +            </pre>
  +
  +            <p>
  +                That's basically all there is to it. If you follow this
  +                pattern consistently, it will be extremely easy to i18n
  +                your application by just putting in place a different
  +                Resources.properties.
  +            </p>
  +            <p>
  +                This i18n package is, indeed, a trivial wrapper around
  +                the built-in i18n features java has using ResourceBundles
  +                and the like. See the java api docs for
  +                <a href="http://java.sun.com/j2se/1.4.1/docs/api/java/util/ResourceBundle.html">ResourceBundle</a>
  +                to learn more about i18n, and take a look at the javadoc
  +                for Resources and ResourceManager to see which options
  +                are available.
               </p>
           </section>
       </body>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message