Hi Evgeny and hi everyone reading,
i've tried all the day to find a workaround but it seems that the
fmt:setLocale is not a solution.
I ended my tests with this basic try that demonstrates that, given two
resources named MyResource_it.properties and MyResource.properties, you cant
switch on the fly the Locale used in a tld.
---- case 1:
<fmt:setBundle basename="MyResource" var="res" /><br/>
<fmt:setLocale value="it" />
Italiano: <fmt:message key="sayhello" bundle="${res}"/><br/>
<fmt:setLocale value="en" />
English: <fmt:message key="sayhello" bundle="${res}"/><br/>
---- result 1:
Italiano: Ciao!
English: Ciao!
---- case 2: (simply switch the order of the setLocale, first en then it)
<fmt:setBundle basename="MyResource" var="res" /><br/>
<fmt:setLocale value="en" />
English: <fmt:message key="sayhello" bundle="${res}"/><br/>
<fmt:setLocale value="it" />
Italiano: <fmt:message key="sayhello" bundle="${res}"/><br/>
---- result 2:
English: Hello!
Italiano: Hello!
so, back to my problem, the ability to localize a <stripes:message/> in
different languages in different areas of the page cant be relied upon a
setLocale, since the setLocale can be set only once before any localized
output.
if u have any idea to achieve this, it would be welcome. otherwise i'm
thinkinkg to write my own <mycustomtag:message /> that accept a lang
parameter
thank u very much
mirko
Evgeny Shepelyuk-2 wrote:
>
> Hello,
>
> I haven't tried it by myself but maybe you can use JSTL fmt:setLocale tag
> in your JSP to set locale partially for part of page ?
>
>>
>> Thank you Evgeny for the quick response.
>>
>> I did as u told me and everything worked as expected.
>> Now I can build a
>> LocalizableMessage message = new LocalizableMessage("msg");
>> and see the correct string rendered in <stripes:messages /> tag
>> accordingly
>> to the navigationLanguage associated to a User.
>>
>> I have now another problem related to my project.
>>
>> Im building a CMS, so in some areas of the thin client the text must be
>> rendered in the navigationLanguage selected (the language of the page
>> given
>> by the LocalePicker), while in the GUI the text must be rendered in the
>> editorLanguage choosen by the operator. In other words an editor can
>> edit a
>> japanese page but the GUI still works in german.
>>
>> The problem is that <stripes:messages /> reads the Locale given by my
>> LocalePicker, and cant distinguish from the page and the GUI. Is there
>> any
>> way to instruct the <stripes:messages /> to use another language?
>>
>> I could build a new custom tag <mycustomtag:messages lang="de" /> that
>> does
>> the same operation of <stripes:messages /> with the ability to receive a
>> parameter to force the language, but I was wandering if there is a
>> cleaner
>> way to achieve my goal
>>
>> thank u again
>>
>> Mirko
>>
>>
>>
>>
>>
>> Evgeny Shepelyuk-2 wrote:
>>>
>>> Hello,
>>>
>>> As i understood probabaly you need to implement own LocalePicker and
>>> then
>>> register it in your web.xml.
>>> This is sample code
>>>
>>>
>>> public class MyLocalePicker implements LocalePicker {
>>>
>>> public Locale pickLocale(HttpServletRequest request) {
>>> //here goes your code to detect locale based on cookie, session, request
>>> parameters etc etc
>>> return ...;
>>> }
>>>
>>> public String pickCharacterEncoding(HttpServletRequest request, Locale
>>> locale) {
>>> return "UTF-8";
>>> }
>>>
>>> public void init(Configuration configuration) throws Exception {
>>> }
>>> }
>>>
>>>>
>>>> Hi everyone,
>>>> its a noob question but something is getting me out of the correct
>>>> path.
>>>>
>>>> I need to internationalize a page, the user will see an English or
>>>> German
>>>> phrase according to the language choosen by clicking a flag: he clicks
>>>> a
>>>> flag, my UserData bean fills its "choosenlocale" field with the
>>>> selected
>>>> Locale and the jsp renders itself in the correct language... beautiful
>>>> but
>>>> it doesnt work.
>>>>
>>>> The problem is that Stripes tags pick the locale in this way:
>>>> Locale locale = getPageContext().getRequest().getLocale();
>>>> (line 250 of InputTagSupport.java) - regardless of the Locale stored
>>>> in
>>>> my
>>>> UserData bean.
>>>>
>>>> Now, i know that it is something about LocalePicker, but i cant really
>>>> understand what to do to with this.
>>>>
>>>> I wrote this in web.xml
>>>>
>>>> <init-param>
>>>> <param-name>LocalePicker.Locales</param-name>
>>>> <param-value>en,de</param-value>
>>>> </init-param>
>>>>
>>>> and then hoped to get my bundles (StripesResources.properties and
>>>> StripesResources_de.properties) work... nothing changes, English shown
>>>> everytime since my browser sends "en" as lang...
>>>>
>>>> please help me
>>>> ty in advance
>>>>
>>>> mirko
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Regards,
>>> Evgeny Shepelyuk
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day
>>> trial. Simplify your report design, integration and deployment - and
>>> focus
>>> on
>>> what you do best, core application coding. Discover what's new with
>>> Crystal Reports now. http://p.sf.net/sfu/bobj-july
>>> _______________________________________________
>>> Stripes-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>>
>>>
>>
>
>
> --
> Regards,
> Evgeny Shepelyuk
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
View this message in context:
http://old.nabble.com/Problem-with-Internationalization-of-StripesResources-tp26377435p26394564.html
Sent from the stripes-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users