litesoft
@ 950
litesoft / trunk / DeviceDesktopTest / src / org / litesoft / servlet / LocalesFromRequest.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
package org.litesoft.servlet; import org.litesoft.locale.*; import javax.servlet.http.*; import java.util.*; public class LocalesFromRequest { public static List<String> getCodes( HttpServletRequest pRequest ) { ArrayList<String> zCodes = new ArrayList<>(); Enumeration zLocales = pRequest.getLocales(); while ( zLocales.hasMoreElements() ) { Locale zLocale = (Locale) zLocales.nextElement(); zCodes.add( AbstractLocale.toCode( zLocale.getLanguage(), zLocale.getCountry() ) ); } return zCodes; } // private Properties supportedLanguages; // private Locale requestLocale = (Locale) supportedLanguages.get("DEFAULT"); // // public LousyServlet() { // supportedLanguages = new Properties(); // // Just for demonstration of the concept // // you would probably load it from i.e. XML // supportedLanguages.put("DEFAULT", Locale.US); // // example mapping of "de" to "de_DE" // supportedLanguages.put("de-DEFAULT", Locale.GERMANY); // supportedLanguages.put("de_AT", new Locale("de", "AT")); // supportedLanguages.put("de_CH", new Locale("de", "CH")); // supportedLanguages.put("ja_JP", Locale.JAPAN); // } // // private void detectLocale(HttpServletRequest request) { // Enumeration locales = request.getLocales(); // while (locales.hasMoreElements()) { // Locale locale = (Locale) locales.nextElement(); // if (supportedLanguages.contains(locale)) { // requestLocale = locale; // break; // } // } // } // // public String getLanguage() { // // get English name of the language // // For native call requestLocale.getDisplayName(requestLocale) // return requestLocale.getDisplayLanguage(); // } } |
Commits for litesoft/trunk/DeviceDesktopTest/src/org/litesoft/servlet/LocalesFromRequest.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
943 Diff | GeorgeS | Tue 03 Jun, 2014 04:25:50 +0000 | Extracting commonfoundation |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
935 Diff | GeorgeS | Fri 30 May, 2014 20:28:08 +0000 | Reformatted. |
931 | GeorgeS | Tue 01 Apr, 2014 20:11:20 +0000 | Locale Support. |