Internationalization with JSF
Hi Everyone,
Here is what happens in my App:
When index.jsp is hit, I determine wether its an authorized/unauthorized login. Based on that user is either forwarded to search/error jsp's. Now I have to add Multi Lingual support to the app. Basically the aplication will be invoked from a portal like app so the URL will look like this :
http://xyz.corp.xyz.com:7780/appsell_uat_xyz/faces/index.jsp?&languageCd=ENG&userId=MPENIKELAPATI
Now I am supposed the pick up the language from the above URL and set the locale accordingly.
I want to set the locale while I am on index.jsp only determing access authority. The way I tried to do this is (I have a bean asociated with index.jsp, this code goes in that bean) :
if(languageCd == "JA"){
context.getViewRoot().setLocale(Locale.JAPANESE);
}
Faces config:
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/search.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>error</from-outcome>
<to-view-id>/error.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
Problem here is if I try to set the local in index.jsp only, viewRoot is not search.jsp yet. So the labels are of default locale. I also tried to set the local in the constructor of search.jsp. This works, but is a very unclean solution as on all the hits code will be executed. One additional problem with this approach is when control is redirecting from index to search jsp, I see all the labels in English for a very small time then the labeles change to Japanease.
I think I dont understand Localization approach of JSF at all. I read local will be picked up from browser setting, but I dont know how will that behave.
I will appreciate a great deal if someone can clear my concepts here!
Thanks in advance!

