Please could someone give me some advice on internationalization best practice for JSF. I know what I am trying to achieve but not the best method. I would appreciate any guidance.
Requirements ============ I want a ResourceBundle accessible to my JSF pages, backing beans and model objects loaded from a properties file. I dont want to load the ResourceBundle for every page or object use, I would like it stored in session scope. The localised resource bundle has to be of the type LC_CC_VC where LC=language, CC=country and VC=variant. I would like to be able to access messages in JSF pages using expression language.
Can anyone advise how I can achieve the above?
Where should I set the Locale in the UIViewRoot? Do I need to set the supported locales in the XML config file? Should I ignore the JSF features and just create my own ResourceBundle and stick it in Session scope? How can I access messages from a resource bundle without having a specific getter?
What would you do?
Thanks for your advice in advance - there are too many options for me to pick the best way to do this.
So far I have tried this route ============================== Extract locale from DB after login Create ResourceBundle in login method of backing bean Store Resourcebundle in session scope
This is OK but it means I cannot use EL to access my messages so I am looking for another solution.
If a view is not associated with a locale explicity, JSF uses "Accept-Language" header in request data from browser to find out the locale to be picked. It compares the header's values with the ones configured in faces-config.xml and if no match is found default locale is selected.
Joined: May 30, 2002
Originally posted by Chris Gage: Please ignore the silly face which the website inserted without asking me. It replaced a colon followed by a letter o with this silly symbol.
Alternatively, while replying you may checkDisable smilies in this post. option at the bottom of the screen
i am coding a "switch language" into an app, and my idea is that i have a bean that stores the language setting. as default, the Accept-language should be used, i.e. in the bean, i would either returned the user defined lanuage or the value of Accept-language.
how can i read out the value of Accept-language from my java code?