1 20 package org.enhydra.barracuda.core.util.l10n; 21 22 import java.util.*; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 26 import org.apache.log4j.*; 27 28 import org.enhydra.barracuda.core.event.*; 29 30 31 37 public class Locales extends org.enhydra.barracuda.plankton.l10n.Locales { 38 39 protected static final Logger logger = Logger.getLogger(Locales.class.getName()); 40 41 49 public static Locale getClientLocale(EventContext ec) { 50 return getClientLocale(ec, LANGAUGE_KEY, COUNTRY_KEY, VARIANT_KEY, PERSIST_DEFAULT); 51 } 52 53 67 public static Locale getClientLocale(EventContext ec, String languageKey, String countryKey, String variantKey, int persistOption) { 68 HttpServletRequest req = (HttpServletRequest) ec.getState(ControlEventContext.HTTP_SERVLET_REQUEST); 69 HttpServletResponse resp = (HttpServletResponse) ec.getState(ViewEventContext.HTTP_SERVLET_RESPONSE); 70 return getClientLocale(req, resp, languageKey, countryKey, variantKey, persistOption); 71 } 72 73 80 public static void saveClientLocale(EventContext ec, Locale loc) { 81 saveClientLocale(ec, loc, PERSIST_DEFAULT); 82 } 83 84 91 public static void saveClientLocale(EventContext ec, Locale loc, int persistOption) { 92 HttpServletRequest req = (HttpServletRequest) ec.getState(ControlEventContext.HTTP_SERVLET_REQUEST); 93 HttpServletResponse resp = (HttpServletResponse) ec.getState(ViewEventContext.HTTP_SERVLET_RESPONSE); 94 saveClientLocale(req, resp, loc, persistOption); 95 } 96 97 105 public static void releaseClientLocale(EventContext ec) { 106 releaseClientLocale(ec, PERSIST_DEFAULT); 107 } 108 109 118 public static void releaseClientLocale(EventContext ec, int persistOption) { 119 HttpServletRequest req = (HttpServletRequest) ec.getState(ControlEventContext.HTTP_SERVLET_REQUEST); 120 HttpServletResponse resp = (HttpServletResponse) ec.getState(ViewEventContext.HTTP_SERVLET_RESPONSE); 121 releaseClientLocale(req, resp); 122 } 123 } 124 | Popular Tags |