jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marius Scurtescu <mar...@multiactive.com>
Subject Re: [VOTE] i18n taglib release
Date Wed, 14 Mar 2001 20:38:45 GMT

Please find my comments below. I kept only some of
the original sections.

Tim Dawson wrote:
> > 2. There should be other ways to set the locale.
> > Relying on the browser settings should be only one
> > of them.
> >
> > In many applications the user explicitly
> > chooses a language/locale and this setting is
> > stored in the session. You should be able to
> > set the locale based on such a setting.
> Fair enough. I'll add an session attribute to store the locale in. The page
> which allows selecting the language/locale would just not use the
> <i18n:localize/> tag -- or else it would read the browser's session. :-)

See comments below.

> > 4. The bundle name can be either set explicitly
> > or it will be retrieved from an attribute/environment.
> >
> > May be the attribute and the environment names
> > should be set explicitly as well instead of using
> > hard coded values.
> > This will make the JSP page more readable as well.
> umm... maybe I didn't understand the first half. how would allowing changing
> the attribute/environments make jsp pages more readable?  those values
> wouldn't be seen inside the jsp pages. one would be seen inside a
> load-on-startup servlet, and the other would be seen inside the deployment
> descriptor.

First, let me clarify this. There are two ways to use 
the "localize" tag:
<i18n:localize bundle="com.wamnet.tools.jsptags.i18n-test"/> 

The second may take the bundle name from an attribute or an 
environment entry. The attribute name and scope and the
environment entry name are hard coded values.

I was proposing to use something like:
<i18n:localize bundle="com.wamnet.tools.jsptags.i18n-test"/> 
<i18n:localize attr="org.apache.taglibs.i18n.LocalizeTag.bundle"/> 
<i18n:localize env="org.apache.taglibs.i18n.LocalizeTag.bundle"/> 

This approach gives you two benefits:
- it makes it clear where the bundle name comes from
- you don't use hard coded values

This would be the clarification.

Now I would like to make some general comments about the
architecture of the whole library.

Here is my understanding of the current architecture:

The main tag in this library is the "message" tag. In order
to provide you with a message it needs a bundle. This
bundle is loaded by "localize" and stored in the "request"
object using a hard coded name, this is where the "message"
tag will look for it. The "localize" tag is also caching
the bundle in the session using a hard coded prefix together
with the bundle name as the attribute name.

In order to load a bundle the "localize" tag has to figure
two things: a bundle base name and a locale. The base name
can be specified as an attribute or it is retrieved from
either the "application" object or from the environment.
The locale is take from the browser preferences.

I can see two limitations to this architecture:
- there is only one way to specify the locale (I addressed
this already in #2 above)
- you can have only one bundle in your page

To overcome these limitations I propose the following

A. Replace the "localize" tag with a "bundle" tag that will
load one bundle and which can have embedded tags

B. Add a "bundle" attribute to the "message" and "require" 
tags to specify which bundle you want to use.

The "bundle" tag would look like:

<i18n:bundle id="bund1">
    <i18n:baseName value="com.wamnet.tools.jsptags.i18n-test"/>
    <i18n:locale language="ro" country="RO"/>


<i18n:bundle id="bund2">
    <i18n:baseName attrib="org.apache.taglibs.i18n.LocalizeTag.bundle" scope="application"/>
    <i18n:locale attrib="org.apache.taglibs.i18n.LocalizeTag.locale.roRO" scope="session"/>


<i18n:bundle id="bund3">
    <i18n:baseName env="org.apache.taglibs.i18n.LocalizeTag.bundle"/>

And the corresponding "message" tag would look like:

<i18n:message bundle="bund1" key="test1" /> 

<i18n:message bundle="bund2" key="test2"> 
this only displayed <em>if</em> 'test2' not found. 

<i18n:message bundle="bund3" key="test1" args="<%= objectArray %>" /> 

May be the "scope" attribute is not needed and we can use

This approach gives the following advantages:
- no hard coded values
- you can use several bundles at the same time
- more flexibility on specifying the base name and the

I don't even have to use the "bundle" tag if a controller servlet
loads the bundle.

I have some other ideas as well, but lets figure this 

What do you think?


View raw message