-
1. Re: Possible bug in LocaleSelector.getSupportedLocales()
joblini Oct 2, 2008 2:14 AM (in response to joblini)Also, it is nice to have the list sorted by display name. Here is my modification, in case anyone finds it useful.
public List<SelectItem> getSupportedLocales() { List<SelectItem> selectItems = new ArrayList<SelectItem>(); Iterator<Locale> locales = FacesContext.getCurrentInstance().getApplication().getSupportedLocales(); TreeMap<String,Locale> sortedLocales = new TreeMap<String,Locale>(); // Sort by display name while ( locales.hasNext() ) { Locale locale = locales.next(); String displayName = locale.getDisplayName(getLocale()); sortedLocales.put(displayName, locale); } // Build the list of select items for (Iterator<Map.Entry<String,Locale>> it=sortedLocales.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String,Locale> entry = (Map.Entry<String,Locale>)it.next(); String displayName = entry.getKey(); Locale locale = entry.getValue(); selectItems.add( new SelectItem( locale.toString(), displayName ) ); } return selectItems; }
-
2. Re: Possible bug in LocaleSelector.getSupportedLocales()
joblini Oct 2, 2008 2:34 AM (in response to joblini)Here is an example of the modification to components.xml to persist the choice of locale using cookies:
<components xmlns:international="http://jboss.com/products/seam/international" ... xsi:schemaLocation=http://jboss.com/products/seam/international http://jboss.com/products/seam/international-2.0.xsd> <international:locale-selector cookie-enabled="true"/>
-
3. Re: Possible bug in LocaleSelector.getSupportedLocales()
pmuir Oct 2, 2008 12:49 PM (in response to joblini)
Ingo Jobling wrote on Oct 02, 2008 01:30:
Wouldn't the desired behavior be to display the list in the language of the current locale?Agreed, create an issue in JIRA and attach a patch :-)
Also, it is nice to have the list sorted by display name. Here is my modification, in case anyone finds it useful.Again, file a JIRA with a patch, but you should use a comparator to sort the list.
-
4. Re: Possible bug in LocaleSelector.getSupportedLocales()
nimo22 Oct 3, 2008 12:26 PM (in response to joblini)Hey Ingo,
I do not like your idea.
Imagine a person speaking (only) english, another speaking only french.
So these two people visit your page. The french person wants to toggle to his/her language and sees these options:
English
French
Spanish
But he/she can not read english and therefore cannot switch to her/his language. It s better to show these options in the way showing the language in the speech depending on the language:
English
espagnol
francaisHe/she can read francais but not neccesseraly french!
So it makes absolutely sense (!), to show each locale its native language. It makes No (!) sense to list all selectable languages in the speech of the current locale.
-
5. Re: Possible bug in LocaleSelector.getSupportedLocales()
nimo22 Oct 3, 2008 12:31 PM (in response to joblini)But this makes absolutely sense:
Also, it is nice to have the list sorted by display name.