Thread: ADF BC: Language / Locale questions


Permlink Replies: 29 - Pages: 2 [ Previous | 1 2 ] - Last Post: Aug 4, 2008 7:29 AM Last Post By: Steve Muench
Steve Muench

Posts: 5,912
Registered: 01/10/01
Re: ADF BC: Language / Locale questions
Posted: Dec 18, 2006 5:10 AM   in response to: Ilya Rodionov in response to: Ilya Rodionov
Click to report abuse...   Click to reply to this thread Reply
Thanks for pointing out this gap in my strategy. I've uploaded an improved example (at the same location and same zip file name) which now uses a custom JSF View Handler and a session-scoped managed bean to do the job.

I've added a button to the "TestPage" in the example that performs a redirect using a global navigation rule to illustrate that this works using this more robust, improved technique.

Thanks.
jackbckw

Posts: 5
Registered: 09/20/99
Re: ADF BC: Language / Locale questions
Posted: Dec 28, 2006 7:40 PM   in response to: Steve Muench in response to: Steve Muench
Click to report abuse...   Click to reply to this thread Reply
Hi,

With the ADF BC demo SR application, the dynamic menu can not change locale during the same session. I have to logout and login again to have the menu label language change. I've tried to change the scope of all menu model beans into request scope. It seems to be fine after that. However, when I implemented the change language button, the dynamic menu labels are not changed as expected until I have to manually click another page or refresh the current page to get the new language menu.

I think the problem is that the binding of MenuItem label is done before the action event listener (I've set the immediate=true for the button, I think it should be executed in Apply Request Value Phase?). Does anyone have the workaround to this problem?

Thank you!
RadoK

Posts: 300
Registered: 06/05/06
Re: ADF BC: Language / Locale questions
Posted: Dec 29, 2006 10:51 AM   in response to: jackbckw in response to: jackbckw
Click to report abuse...   Click to reply to this thread Reply
Hi,
I had a similar problem with label for pages. The page label value was defined in pageDef as variable and its value was from resource bundle: "#{res.myPageLabel}.
Its translation was late one click when language switch occured.
I solved this problem by creating managed bean for labels. The bean contains get method for each label (for example getMyLabel). The method returns translated label from resource bundle.
Now my pageDef variable value is defined as #{myResourceBean.myLabel} and it works for me.

Rado
jackbckw

Posts: 5
Registered: 09/20/99
Re: ADF BC: Language / Locale questions
Posted: Jan 1, 2007 5:39 PM   in response to: RadoK in response to: RadoK
Click to report abuse...   Click to reply to this thread Reply
Thanks for your reply.

Unfortunately, the MenuItem managed bean uses managed property to get the translated label. I have no idea how I can control when the managed property get assigned with value from another managed application scoped resource bundle bean. I have already changed the MenuItem bean from session scope to request scope and expect it can be reconstructed everytime a new request was received. However, it looks to me that the managed bean was constructed before the action handler for the switching language button get called. More importantly, the menuitem bean's label was assigned at the same time as the bean being created. This will make the translation of the label happen at the next cycle of the request.

Does anyone have other alternative?
Thank you in advance!

Regards,
Jack Wu
RadoK

Posts: 300
Registered: 06/05/06
Re: ADF BC: Language / Locale questions
Posted: Jan 2, 2007 2:42 AM   in response to: jackbckw in response to: jackbckw
Click to report abuse...   Click to reply to this thread Reply
Hi,

Unfortunately, the MenuItem managed bean uses managed property
to get the translated label

What does your managed bean property value look like now?

Rado
jackbckw

Posts: 5
Registered: 09/20/99
Re: ADF BC: Language / Locale questions
Posted: Jan 2, 2007 3:00 AM   in response to: RadoK in response to: RadoK
Click to report abuse...   Click to reply to this thread Reply
Thanks for your reply.

I've finally solved the problem as implementing the MenuItem.getLabel() method as follow:

public String getLabel() {
return JSFUtils.getStringFromBundle(_label);
}

Before, I was using static bind to set the MenuItem's label managed property as #{res['key.to.label.text']}. Now, I've changed the managed property to just the key for the message and have the MenuItem's getLabel() method to get the label text at a later time.

Thank you!
Regards,
Jack Wu

jackbckw

Posts: 5
Registered: 09/20/99
Re: ADF BC: Language / Locale questions
Posted: Jan 17, 2007 8:18 PM   in response to: jackbckw in response to: jackbckw
Click to report abuse...   Click to reply to this thread Reply
Hi,

I've tried to localize the message text for a list binding for null message. That means in the List Binding Editor --> "No Selection" Item: --> Include Labeled Item --> <Any Selection>. I want to localize the text "<Any Selection>" in other language. I've created a new message bundle. After all, I tested the same change language function, it does not work immediately. I have to refresh the page to have the text changed to the desired language. Does anyone have workaround on this?

Thank you!
Regards,
Jack Wu
Steve Muench

Posts: 5,912
Registered: 01/10/01
Re: ADF BC: Language / Locale questions
Posted: Jan 18, 2007 3:27 AM   in response to: jackbckw in response to: jackbckw
Click to report abuse...   Click to reply to this thread Reply
This was a subtle problem related to the fact that the List Binding prepares its list of valid choices (including the automatically-added "null" entry with translatable label) during the prepareModel phase of the lifecycle, to avoid recalculating the list during the prepareRender phase.

I've updated my example #95 to accommodate having this work correctly.

http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#95

This required changing the implementation from using a JSF View Handler to performing that work in a custom FacesPageLifecycle class in an overridden prepareRender() method instead.

Please re-download the example zip to experiment with the improved implementation.

Thanks for finding this little niggle!
Brokenbone

Posts: 456
Registered: 03/13/07
Re: ADF BC: Language / Locale questions
Posted: Aug 17, 2007 1:49 AM   in response to: Steve Muench in response to: Steve Muench
Click to report abuse...   Click to reply to this thread Reply
Hi all!

It's been a while since last post in this thread but I hope to get some more answers. First I'd like to thank you for this example. I've done something like this with my application but now I ran into two problems with the managed bean holding preferedLocale has session scope.

In my project I have two public pages and a link to application home page that calls login page when user is not logged in.

1) Login page always uses the english resources even though default and currently active locale is different. (edit: OK, I think I figured this out: probably becouse default resource file (one without suffix) is for english)
2) Since bean scope is session after login (another session probably) user selected locale is forgotten (same with logout). How can I pass preffered locale to another session? Application scope for this bean is not good for me since it changes locale for all users that are currently using the application.

I'm quite new to JDeveloper and web applications so my questions are sometimes a bit stupid. I hope these aren't one of them :).

Thank you!
Bye

Message was edited by:
Brokenbone
Brokenbone

Posts: 456
Registered: 03/13/07
Re: ADF BC: Language / Locale questions
Posted: Aug 19, 2007 11:29 PM   in response to: Brokenbone in response to: Brokenbone
Click to report abuse...   Click to reply to this thread Reply
With "I figured it out" I don't mean I solved it :). I still don't know why login page takes the default resource file (the one without _locale at the end of the name).

I still hope to get some pointer to solve this.
Cheers!
Patrik Varga

Posts: 360
Registered: 11/20/06
Re: ADF BC: Language / Locale questions
Posted: Sep 12, 2007 4:40 AM   in response to: jackbckw in response to: jackbckw
Click to report abuse...   Click to reply to this thread Reply
Hi,

it seems that there are other problems with SR demo regarding changing locale. For example:
- if I run the page with browser locale set to German, the menu tabs (which are based on the menu model, this is the menu1 facet) are always shown in English,
- on the SRCreate page there are English and German messages at the same time (English: buttons, title, userInfo, copyright, about; German: all other texts including menuGlobal and dropdown lists).

In a different application, localization for menu items based on menu model also did not work by default.
Jackbckw, thanks for solution - returning JSFUtils.getStringFromBundle(_label) in MenuItem.getLabel() work fine!

Regards,
Patrik

nermin

Posts: 11
Registered: 10/15/07
Re: ADF BC: Language / Locale questions
Posted: Jan 29, 2008 2:28 AM   in response to: RadoK in response to: RadoK
Click to report abuse...   Click to reply to this thread Reply
I wrote about this earlier in another thread but nobody answered me. I don't know how can I create bosnian translation of text that is a part of ADF components -- for example text "select" in selection column of af:table component that automaticaly changes to "seleziona" when I change browser language from english to italian.
Steve Muench

Posts: 5,912
Registered: 01/10/01
Re: ADF BC: Language / Locale questions
Posted: Jan 29, 2008 3:04 AM   in response to: nermin in response to: nermin
Click to report abuse...   Click to reply to this thread Reply
user616170

Posts: 29
Registered: 01/22/08
Re: ADF BC: Language / Locale questions
Posted: Aug 3, 2008 1:14 AM   in response to: Ilya Rodionov in response to: Ilya Rodionov
Click to report abuse...   Click to reply to this thread Reply
I have followed <Localizing JSF and ADF Faces applications>
Written by Jonas Jacobi, Oracle Corporation
August, 2005
Revision 1.0

have learned to set IE to ug to display uighur.jsp, or bo to display Tibet.jsp, OK!
I have download ChangeLanguageInTheUI.zip , Open in my jdeveloper10.1.3.3, Ok!
sorry I am a new , know little,
Please demo how to "ChangeLanguageInTheUI", the process?
another question: I want if locale=ug(uighur, one of arabic) , the jsp dir=rtl.
Thanks.
Steve Muench

Posts: 5,912
Registered: 01/10/01
Re: ADF BC: Language / Locale questions
Posted: Aug 4, 2008 7:29 AM   in response to: user616170 in response to: user616170
Click to report abuse...   Click to reply to this thread Reply
Please start a new thread with a new question. Thanks.
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums