You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2007/09/02 18:23:15 UTC

internationalised strings in the database

It would be great if someone could give me some insights into possible ways of 
leveraging tiles2 in order to provide translating facilities on a page by page 
basis for a website, where the translated strings are kept in a database, 
indexed by the JSP where they are used and a non-unique name (e.g. title).

(1) is it possible to write a taglib that could work out automatically what the 
name of its JSP is?

(2) given no. 1 is possible, would it be possible to work out the name of the 
master tile that the taglib is in, in order to quote that tile in a URL param 
like this:

app/somepage/translate?thisTile=xyz

so that the 'translate' page could retrieve and display translated strings in a 
form for all JSPs used by the master tile?


Thanks and regards
Adam


Re: internationalised strings in the database

Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/3, Adam Hardy <ah...@cyberspaceroad.com>:
> In another tag to produce a url to a translation page, I must work out the name
> of the 'master' tile that this JSP is part of.

You cannot know, in a JSP page, what is the definition that contains
it, however you can circumvent your problem.
You could use a preparer for your definition, that puts a
request-scoped bean that is the prefix of the partial key. For
preparers, see:
http://tiles.apache.org/tutorial/advanced/preparer.html

Antonio

Re: internationalised strings in the database

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
>>>> (1) is it possible to write a taglib that could work out automatically
>> what the name of its JSP is?

>>>> (2) given no. 1 is possible, would it be possible to work out the name
>> of the master tile that the taglib is in, in order to quote that tile in a URL
>> param like this:
>>>> 
>>>> app/somepage/translate?thisTile=xyz

Those are my issues. What I am trying to make clear is the mechanism by which my 
fmt:message taglib implementation would be able to identify automatically which 
i18n string to retrieve, when given only a non-unique key such as "title".

<adam:message key="title"/>

The class should work out the JSP name itself.

In another tag to produce a url to a translation page, I must work out the name 
of the 'master' tile that this JSP is part of.

That translation page must establish the names of all the JSPs involved in the 
tile. In this way it can retrieve all strings used on that page and present them 
in a form for translation.

There is already an implementation of i18n resources that reads from a database 
that I can use.

Regards
Adam

Re: internationalised strings in the database

Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/3, Adam Hardy <ah...@cyberspaceroad.com>:
>
> Antonio Petrelli on 03/09/07 08:02, wrote:
> > 2007/9/2, Adam Hardy <ah...@cyberspaceroad.com>:
> >> It would be great if someone could give me some insights into possible
> ways of
> >> leveraging tiles2 in order to provide translating facilities on a page
> by page
> >> basis for a website, where the translated strings are kept in a
> database,
> >> indexed by the JSP where they are used and a non-unique name (e.g.
> title).
> >>
> >> (1) is it possible to write a taglib that could work out automatically
> what the
> >> name of its JSP is?
> >>
> >> (2) given no. 1 is possible, would it be possible to work out the name
> of the
> >> master tile that the taglib is in, in order to quote that tile in a URL
> param
> >> like this:
> >>
> >> app/somepage/translate?thisTile=xyz
> >>
> >> so that the 'translate' page could retrieve and display translated
> strings in a
> >> form for all JSPs used by the master tile?
> >
> > The standard way of using internationalized string is (if you are
> > using plain JSP) JSTL <fmt:message> tag:
> > http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/message.html
>
> Thanks for your reply. Unfortunately due to the requirements described in
> detail
> above, that fmt:message solution doesn't apply here.



Why? You can create a composite ID, such as:
pageName.title
and use it as the key of the i18n string.
Moreover, ResourceBundle is a class: you can implement you version that
connects to a DB.

Antonio

Re: internationalised strings in the database

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Antonio Petrelli on 03/09/07 08:02, wrote:
> 2007/9/2, Adam Hardy <ah...@cyberspaceroad.com>:
>> It would be great if someone could give me some insights into possible ways of
>> leveraging tiles2 in order to provide translating facilities on a page by page
>> basis for a website, where the translated strings are kept in a database,
>> indexed by the JSP where they are used and a non-unique name (e.g. title).
>>
>> (1) is it possible to write a taglib that could work out automatically what the
>> name of its JSP is?
>>
>> (2) given no. 1 is possible, would it be possible to work out the name of the
>> master tile that the taglib is in, in order to quote that tile in a URL param
>> like this:
>>
>> app/somepage/translate?thisTile=xyz
>>
>> so that the 'translate' page could retrieve and display translated strings in a
>> form for all JSPs used by the master tile?
> 
> The standard way of using internationalized string is (if you are
> using plain JSP) JSTL <fmt:message> tag:
> http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/message.html

Thanks for your reply. Unfortunately due to the requirements described in detail 
above, that fmt:message solution doesn't apply here.

Any further advice would be greatly appreciated.


Regards
Adam



Re: internationalised strings in the database

Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/2, Adam Hardy <ah...@cyberspaceroad.com>:
> It would be great if someone could give me some insights into possible ways of
> leveraging tiles2 in order to provide translating facilities on a page by page
> basis for a website, where the translated strings are kept in a database,
> indexed by the JSP where they are used and a non-unique name (e.g. title).
>
> (1) is it possible to write a taglib that could work out automatically what the
> name of its JSP is?
>
> (2) given no. 1 is possible, would it be possible to work out the name of the
> master tile that the taglib is in, in order to quote that tile in a URL param
> like this:
>
> app/somepage/translate?thisTile=xyz
>
> so that the 'translate' page could retrieve and display translated strings in a
> form for all JSPs used by the master tile?

The standard way of using internationalized string is (if you are
using plain JSP) JSTL <fmt:message> tag:
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/message.html

Antonio