You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Todd Wilkinson <lp...@dealsqueal.com> on 2007/05/22 17:52:02 UTC

Tiles2 Localization

Hello-
I want to use tiles2 for an upcoming project and I have a question about
localization.  Please forgive me if my question goes beyond tiles-specific
and into general localization concerns.
I would like to be able to localize beyond just language and country. 
Ideally, I would like to have up to 3 additional criteria on which to
localize - eg, state, county, etc.  Is this possible in tiles?
I have viewed the tiles localization documentation page here :
http://tiles.apache.org/tutorial/advanced/l10n.html

I don't quite understand how tiles knows which convention to follow:
tiles_defs_<language>.xml or tiles_defs_<language>_<country>.xml as used
in the examples, or in my case:
tiles_defs_<language>_<country>_<state>_<city>.xml if possible.

also, it is unclear to me how the runtime decides the locale to choose -
ie, how does tiles know the locale of the request?

Thanks!


Re: Tiles2 Localization

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/23, Todd Wilkinson <lp...@dealsqueal.com>:
>
> However I do have one follow-up
> question - tiles only seems to 'cascade' the definitions from the general
> tiles-defs.xml and the specific locale file.  I have templates and content
> that may apply to a whole state, and would like to override on multiple
> levels: tiles-defs.xml -> tiles-defs_en_US_state.xml ->
> tiles-defs_en_US_state_city.xml
>
> Where does the loading of the defs files take place?



The loading takes place (for default) in DigesterDefinitionsReader:
http://tiles.apache.org/framework/apidocs/org/apache/tiles/definition/digester/DigesterDefinitionsReader.html
While the definition inheritances are calculated in DefinitionsImpl:
http://tiles.apache.org/framework/apidocs/org/apache/tiles/definition/DefinitionsImpl.html

HTH
Antonio

Re: Tiles2 Localization

Posted by Todd Wilkinson <lp...@dealsqueal.com>.
Thank you Antonio!
Your comments were very helpful.

For clarity in the thread - Tiles will read the locale form a session
attribute with the same name as the LOCALE_KEY constant.  I was able to
set this and it worked fine.

The Locale object has parameters language and country, as well as a third
parameter - 'variant' which it will append when resolving the locale.  By
specifying my own convention within the variant, i was able to create
customized locales such as - en_US_state_city (where "_state_city" is the
variant), and tiles would load a defs file named
tiles-defs_en_US_state_city.xml .  However I do have one follow-up
question - tiles only seems to 'cascade' the definitions from the general
tiles-defs.xml and the specific locale file.  I have templates and content
that may apply to a whole state, and would like to override on multiple
levels: tiles-defs.xml -> tiles-defs_en_US_state.xml ->
tiles-defs_en_US_state_city.xml

Where does the loading of the defs files take place?

Thanks again!

> 2007/5/22, Todd Wilkinson <lp...@dealsqueal.com>:
>> I would like to be able to localize beyond just language and country.
>> Ideally, I would like to have up to 3 additional criteria on which to
>> localize - eg, state, county, etc.  Is this possible in tiles?
>
> It's possible, but you have to code a bit :-)
> You have to extend the UrlDefinitionFactory class and then configure it.
> As an example, you can see Dimensions:
> http://mutidimensions.sf.net/
> You've got to download the trunk from the Subversion repository.
> Notice that it probably won't build, but at least you'll get the point
> :-)
> http://mutidimensions.svn.sourceforge.net/mutidimensions/framework/trunk/
>
>> I have viewed the tiles localization documentation page here :
>> http://tiles.apache.org/tutorial/advanced/l10n.html
>>
>> I don't quite understand how tiles knows which convention to follow:
>
> It follows the standard for Locales. See:
> http://java.sun.com/developer/technicalArticles/Intl/IntlIntro/
>
>> also, it is unclear to me how the runtime decides the locale to choose -
>> ie, how does tiles know the locale of the request?
>
> See DefaultLocaleResolver class for this:
> http://tiles.apache.org/framework/apidocs/org/apache/tiles/locale/impl/DefaultLocaleResolver.html
>
> HTH
> Antonio
>



Re: Tiles2 Localization

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/22, Todd Wilkinson <lp...@dealsqueal.com>:
> I would like to be able to localize beyond just language and country.
> Ideally, I would like to have up to 3 additional criteria on which to
> localize - eg, state, county, etc.  Is this possible in tiles?

It's possible, but you have to code a bit :-)
You have to extend the UrlDefinitionFactory class and then configure it.
As an example, you can see Dimensions:
http://mutidimensions.sf.net/
You've got to download the trunk from the Subversion repository.
Notice that it probably won't build, but at least you'll get the point
:-)
http://mutidimensions.svn.sourceforge.net/mutidimensions/framework/trunk/

> I have viewed the tiles localization documentation page here :
> http://tiles.apache.org/tutorial/advanced/l10n.html
>
> I don't quite understand how tiles knows which convention to follow:

It follows the standard for Locales. See:
http://java.sun.com/developer/technicalArticles/Intl/IntlIntro/

> also, it is unclear to me how the runtime decides the locale to choose -
> ie, how does tiles know the locale of the request?

See DefaultLocaleResolver class for this:
http://tiles.apache.org/framework/apidocs/org/apache/tiles/locale/impl/DefaultLocaleResolver.html

HTH
Antonio