Problems with locale,please help me...

G

gbattine

Hi guys,
i'm trying to solve this problem but nothing!!!!
I've a jsf application with 2 languages,italian(default )and english.
I have an italian resource bundle and an english one.
When i run the application and i select in a page english versione,all
the pages became in english,but application message like validator msg
etc....are still in italian!!
In my bean i've
Locale
locale=getFacesContext().getExternalContext().getRequestLocale();
System.out.println(locale);
ResourceBundle rb =
ResourceBundle.getBundle("microarray.bundle.messageResource", locale);
String result = rb.getString("groupPresent");
System.out.println(result);[/code

when i'm in english mode and i click on a submit botton i see
it
the message in italian,

because the locale it retrieves is ITALIAN, so the message is in
italian.
But i'm in english mode!!!!!!!
This is my faces config.xml
Code:
<application>
  <message-bundle>microarray.bundle.messageResource</message-bundle>
  <locale-config>
   <default-locale>it</default-locale>
   <supported-locale>it</supported-locale>
   <supported-locale>en</supported-locale>
  </locale-config>
 </application>



and this is my method to populate dropdown list of locales...please
help me...


public List getSupportedtLocaleItems()
	  {
	    if (localeItems == null)
	    {
	      localeItems = new ArrayList();
	      Application app =
FacesContext.getCurrentInstance().getApplication();
	      for (Iterator i = app.getSupportedLocales(); i.hasNext(); )
	      {
	        Locale locale = (Locale)i.next();
	        SelectItem item = new SelectItem(locale.toString(),
locale.getDisplayName());
	        localeItems.add(item);
	      }
	      if (localeItems.size() == 0)
	      {
	        Locale defaultLocale = app.getDefaultLocale();
	        localeItems.add(new SelectItem(defaultLocale.toString(),
defaultLocale.getDisplayName()));
	      }
	    }
	    return localeItems;
	  }
	public String getLocale()
	  {
	    return
FacesContext.getCurrentInstance().getViewRoot().getLocale().toString();
	  }

	  public void setLocale(String locale)
	  {
	    FacesContext.getCurrentInstance().getViewRoot().setLocale(new
Locale(locale));
	  }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top