package kernel.web;
|
|
import java.util.Locale;
|
|
/* */ import javax.servlet.http.HttpServletRequest;
|
/* */ import javax.servlet.http.HttpServletRequestWrapper;
|
/* */ import javax.servlet.http.HttpSession;
|
|
public class I18NRequestWrapper extends HttpServletRequestWrapper
|
{
|
private Locale locale = null;
|
|
|
public I18NRequestWrapper(HttpServletRequest request) {
|
super(request);
|
HttpSession session = request.getSession();
|
Object object = session.getAttribute("WW_TRANS_I18N_LOCALE");
|
if (object != null) {
|
this.locale = ((Locale) session.getAttribute("WW_TRANS_I18N_LOCALE"));
|
}
|
else this.locale = Locale.TAIWAN;
|
}
|
|
|
public String getHeader(String name)
|
{
|
String value = super.getHeader(name);
|
if (("Accept-Language".equals(name)) && (this.locale != null)) {
|
value = this.locale.getLanguage() + "_" + this.locale.getCountry()
|
+ value.substring(6, value.length());
|
}
|
return value;
|
}
|
|
|
public Locale getLocale()
|
{
|
if (this.locale != null) {
|
return this.locale;
|
}
|
return super.getLocale();
|
}
|
}
|