Hi!
Yes this is a possibillity. But what if I already have different
forwards for my action: "success", "info", "lalala". I will have to
change this to "success_en", "info_en", "lalala_en" and to add
"success_fr", "info_fr", "lalala_fr" and to include additional logic to
action to check what language is requested by user. This logic can be
extracted to all actions base class.
But what if I would like to include new languages? Normal step I would
like to perform is just to create new (approprietly named) jsp's not to
rewrite the whole struts-config and to add lots of new forwards:
"success_es", "info_es", "lalala_es", like this.
Here I can propose to override mapping.findForward or somehow like this...
In this case findForward would check the user requested language, find a
forward path add/insert locale suffix and return link to file.
Please comment, what do you think about this?
Best regards
Yaroslav Novytskyy
P.S. this will be not compatible with tiles :(
Glenn DeschĂȘnes wrote:
What you can do is have a jsp for each locale language such as
page_fr.jsp and page_en.jsp.
Your application can store the locale in the user's session object.
Your application can update the session locale when the user switches
between en & fr.
You can have the following forwards for the action in the struts-config.xml:
<forward name="en" path="/WEB-INF/page_en.jsp">
</forward>
<forward name="fr" path="/WEB-INF/page_fr.jsp">
</forward>
In your ActionForm you can:
return mapping.findForward(get the locale language from the session);
HTH,
Glenn
On 6/24/05, Yaroslav Novytskyy <[EMAIL PROTECTED]> wrote:
Hello, all!
I just wonder if there is an existing (tested, prooved) way (a kind of
development pattern) for Struts to make internationalization not by
message resources but by pages (JSPs, templates)?
The point is that using message resources deleloper can only define a
string value for different locales. For example for "en" welcome=aaa
for "fr" welcome=bbb, and you include it like <title><out
"welcome"></title>. This produces "<title>aaa</title>" for "en" and
"<title>bbb</title>" for "fr".
That makes you limited to localizing only strings, but not the format.
E.G. I would like to output "<title>aaa</title>" for "en" and
"<h1>bbb</h1>" for "fr". And this not the matter of defining this
strings (<h1>bbb</h1>) in message bundles, but I would like to use
separate JSPs for "en" and "fr" and that is the point. I would like have
two jsp files: page1.en.jsp with content of "<title>aaa</title>" and
page1.fr.jsp with "<h1>bbb</h1>". (P.S. this reduces much (maybe even
terminates) the mess with message bundles).
Please write all your suggestions and thoughts.
Best regards
Yaroslav Novytskyy
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]