Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.75 -r1.76
--- lams_central/conf/language/lams/ApplicationResources.properties 23 Apr 2009 00:02:34 -0000 1.75
+++ lams_central/conf/language/lams/ApplicationResources.properties 27 Apr 2009 19:37:17 -0000 1.76
@@ -321,6 +321,36 @@
label.planner.export.sequence=Export sequence
error.planner.export.template=There was an error while exporting the template.
-
-
+label.timezone.title=Time Zone
+label.timezone.0=(GMT -12:00) Eniwetok, Kwajalein
+label.timezone.1=(GMT -11:00) Midway Island, Samoa
+label.timezone.2=(GMT -10:00) Hawaii
+label.timezone.3=(GMT -9:00) Alaska
+label.timezone.4=(GMT -8:00) Pacific Time (US & Canada)
+label.timezone.5=(GMT -7:00) Mountain Time (US & Canada)
+label.timezone.6=(GMT -6:00) Central Time (US & Canada), Mexico City
+label.timezone.7=(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima
+label.timezone.8=(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz
+label.timezone.9=(GMT -3:30) Newfoundland
+label.timezone.10=(GMT -3:00) Brazil, Buenos Aires, Georgetown
+label.timezone.11=(GMT -2:00) Mid-Atlantic
+label.timezone.12=(GMT -1:00 hour) Azores, Cape Verde Islands
+label.timezone.13=(GMT) Western Europe Time, London, Lisbon, Casablanca
+label.timezone.14=(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris
+label.timezone.15=(GMT +2:00) Kaliningrad, South Africa
+label.timezone.16=(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg
+label.timezone.17=(GMT +3:30) Tehran
+label.timezone.18=(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi
+label.timezone.19=(GMT +4:30) Kabul
+label.timezone.20=(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent
+label.timezone.21=(GMT +5:30) Bombay, Calcutta, Madras, New Delhi
+label.timezone.22=(GMT +5:45) Kathmandu
+label.timezone.23=(GMT +6:00) Almaty, Dhaka, Colombo
+label.timezone.24=(GMT +7:00) Bangkok, Hanoi, Jakarta
+label.timezone.25=(GMT +8:00) Beijing, Perth, Singapore, Hong Kong
+label.timezone.26=(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk
+label.timezone.27=(GMT +9:30) Adelaide, Darwin
+label.timezone.28=(GMT +10:00) Eastern Australia, Guam, Vladivostok
+label.timezone.29=(GMT +11:00) Magadan, Solomon Islands, New Caledonia
+label.timezone.30=(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka
#======= End labels: Exported 229 labels for en AU =====
Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources_en_AU.properties,v
diff -u -r1.71 -r1.72
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 23 Apr 2009 00:02:34 -0000 1.71
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 27 Apr 2009 19:37:17 -0000 1.72
@@ -321,6 +321,37 @@
label.planner.export.sequence=Export sequence
error.planner.export.template=There was an error while exporting the template.
+label.timezone.title=Time Zone
+label.timezone.0=(GMT -12:00) Eniwetok, Kwajalein
+label.timezone.1=(GMT -11:00) Midway Island, Samoa
+label.timezone.2=(GMT -10:00) Hawaii
+label.timezone.3=(GMT -9:00) Alaska
+label.timezone.4=(GMT -8:00) Pacific Time (US & Canada)
+label.timezone.5=(GMT -7:00) Mountain Time (US & Canada)
+label.timezone.6=(GMT -6:00) Central Time (US & Canada), Mexico City
+label.timezone.7=(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima
+label.timezone.8=(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz
+label.timezone.9=(GMT -3:30) Newfoundland
+label.timezone.10=(GMT -3:00) Brazil, Buenos Aires, Georgetown
+label.timezone.11=(GMT -2:00) Mid-Atlantic
+label.timezone.12=(GMT -1:00 hour) Azores, Cape Verde Islands
+label.timezone.13=(GMT) Western Europe Time, London, Lisbon, Casablanca
+label.timezone.14=(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris
+label.timezone.15=(GMT +2:00) Kaliningrad, South Africa
+label.timezone.16=(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg
+label.timezone.17=(GMT +3:30) Tehran
+label.timezone.18=(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi
+label.timezone.19=(GMT +4:30) Kabul
+label.timezone.20=(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent
+label.timezone.21=(GMT +5:30) Bombay, Calcutta, Madras, New Delhi
+label.timezone.22=(GMT +5:45) Kathmandu
+label.timezone.23=(GMT +6:00) Almaty, Dhaka, Colombo
+label.timezone.24=(GMT +7:00) Bangkok, Hanoi, Jakarta
+label.timezone.25=(GMT +8:00) Beijing, Perth, Singapore, Hong Kong
+label.timezone.26=(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk
+label.timezone.27=(GMT +9:30) Adelaide, Darwin
+label.timezone.28=(GMT +10:00) Eastern Australia, Guam, Vladivostok
+label.timezone.29=(GMT +11:00) Magadan, Solomon Islands, New Caledonia
+label.timezone.30=(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka
-
#======= End labels: Exported 229 labels for en AU =====
Index: lams_central/conf/xdoclet/struts-forms.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/struts-forms.xml,v
diff -u -r1.8 -r1.9
--- lams_central/conf/xdoclet/struts-forms.xml 13 Feb 2009 17:45:44 -0000 1.8
+++ lams_central/conf/xdoclet/struts-forms.xml 27 Apr 2009 19:37:17 -0000 1.9
@@ -32,6 +32,7 @@
org.lamsfoundation.lams.web.session.SystemSessionFilter
- * in web.xml because it need get value from SystemSession .
+ * Filter request to preferred locale according to user option in database, client browser locale or default locale. The
+ * proity is user setting in database is highest, then browser locale, then the default locale.
+ *
+ * NOTICE: This filter must set after org.lamsfoundation.lams.web.session.SystemSessionFilter
in
+ * web.xml because it need get value from SystemSession .
*
* @author Steve.Ni
*
* @version $Revision$
*/
public class LocaleFilter extends OncePerRequestFilter {
-
-// private static Logger log = Logger.getLogger(LocaleFilter.class);
- private String encoding;
-
- public static final String PREFERRED_LOCALE_KEY = "org.apache.struts.action.LOCALE";
- /** Key used in request to get the required direction. Used by the HTML tag */
- public static final String DIRECTION = "page_direction";
-
- /**
- * Set the encoding to use for requests. This encoding will be
- * passed into a ServletRequest.setCharacterEncoding call.
- */
- public void setEncoding(String encoding) {
- this.encoding = encoding;
+
+ // private static Logger log = Logger.getLogger(LocaleFilter.class);
+ private String encoding;
+
+ public static final String PREFERRED_LOCALE_KEY = "org.apache.struts.action.LOCALE";
+ /** Key used in request to get the required direction. Used by the HTML tag */
+ public static final String DIRECTION = "page_direction";
+
+ /**
+ * Set the encoding to use for requests. This encoding will be passed into a ServletRequest.setCharacterEncoding
+ * call.
+ */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ @Override
+ public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
+ // charset encoding
+ if (!StringUtils.isEmpty(encoding)) {
+ request.setCharacterEncoding(encoding);
+ } else {
+ request.setCharacterEncoding("UTF-8");
}
-
- public void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
- FilterChain chain) throws IOException, ServletException {
- //charset encoding
- if(!StringUtils.isEmpty(this.encoding))
- request.setCharacterEncoding(encoding);
- else
- request.setCharacterEncoding("UTF-8");
-
- Locale preferredLocale = null;
- String direction = null;
- TimeZone tz = null;
- //Comment: This getParameter() cause problem when reading WDDX packet, which need request.getInputStream() method.
- //user set has first prority:
-// String locale = request.getParameter("locale");
-// if (locale != null)
-// preferredLocale = new Locale(locale);
- //if request does not assign locale, then get it from database
- if(preferredLocale == null){
- HttpSession sharedsession = SessionManager.getSession();
- if(sharedsession != null){
- UserDTO user = (UserDTO) sharedsession.getAttribute(AttributeNames.USER);
- if(user != null){
- direction = user.getDirection();
- tz = user.getTimeZone();
- String lang = user.getLocaleLanguage();
- String country = user.getLocaleCountry();
- // would prefer both the language and country but that's not always feasible.
- // so we may end up with some confusing situations.
- if(!StringUtils.isEmpty(lang)){
- preferredLocale = new Locale(lang,country!=null?country:"");
- }
- }
- }
- }
- if(preferredLocale == null){
- //if request does not have, set it default then.
- String defaults[] = LanguageUtil.getDefaultLangCountry();
- preferredLocale = new Locale(defaults[0]!=null?defaults[0]:"",
- defaults[1]!=null?defaults[1]:"");
-
- }
+ Locale preferredLocale = null;
+ String direction = null;
+ TimeZone tz = null;
+ // Comment: This getParameter() cause problem when reading WDDX packet, which need request.getInputStream()
+ // method.
+ // user set has first prority:
+ // String locale = request.getParameter("locale");
+ // if (locale != null)
+ // preferredLocale = new Locale(locale);
- if(direction == null){
- direction = LanguageUtil.getDefaultDirection();
+ // if request does not assign locale, then get it from database
+ if (preferredLocale == null) {
+ HttpSession sharedsession = SessionManager.getSession();
+ if (sharedsession != null) {
+ UserDTO user = (UserDTO) sharedsession.getAttribute(AttributeNames.USER);
+ if (user != null) {
+ direction = user.getDirection();
+ tz = user.getTimeZone();
+ String lang = user.getLocaleLanguage();
+ String country = user.getLocaleCountry();
+ // would prefer both the language and country but that's not always feasible.
+ // so we may end up with some confusing situations.
+ if (!StringUtils.isEmpty(lang)) {
+ preferredLocale = new Locale(lang, country != null ? country : "");
+ }
}
- if(tz == null) {
- LanguageUtil.getDefaultTimeZone();
- }
+ }
+ }
+ if (preferredLocale == null) {
+ // if request does not have, set it default then.
+ String defaults[] = LanguageUtil.getDefaultLangCountry();
+ preferredLocale = new Locale(defaults[0] != null ? defaults[0] : "", defaults[1] != null ? defaults[1] : "");
- HttpSession session = request.getSession(false);
- //set locale for STURTS and JSTL
- // set the time zone - must be set for dates to display the time zone
- if (session != null) {
- if (preferredLocale != null) {
- session.setAttribute(PREFERRED_LOCALE_KEY, preferredLocale);
- Config.set(session, Config.FMT_LOCALE, preferredLocale);
- session.setAttribute(DIRECTION, direction);
- }
- Config.set(session, Config.FMT_TIME_ZONE, tz);
- }
- if (preferredLocale != null && !(request instanceof LocaleRequestWrapper)) {
- request = new LocaleRequestWrapper(request, preferredLocale);
- LocaleContextHolder.setLocale(preferredLocale);
- }
+ }
- if(chain != null)
- chain.doFilter(request, response);
-
- // Reset thread-bound LocaleContext.
- LocaleContextHolder.setLocaleContext(null);
+ if (direction == null) {
+ direction = LanguageUtil.getDefaultDirection();
}
+ if (tz == null) {
+ LanguageUtil.getDefaultTimeZone();
+ }
+ HttpSession session = request.getSession(false);
+ // set locale for STURTS and JSTL
+ // set the time zone - must be set for dates to display the time zone
+ if (session != null) {
+ if (preferredLocale != null) {
+ session.setAttribute(LocaleFilter.PREFERRED_LOCALE_KEY, preferredLocale);
+ Config.set(session, Config.FMT_LOCALE, preferredLocale);
+ session.setAttribute(LocaleFilter.DIRECTION, direction);
+ }
+ Config.set(session, Config.FMT_TIME_ZONE, tz);
+ }
+ if (preferredLocale != null && !(request instanceof LocaleRequestWrapper)) {
+ request = new LocaleRequestWrapper(request, preferredLocale);
+ LocaleContextHolder.setLocale(preferredLocale);
+ }
+ if (chain != null) {
+ chain.doFilter(request, response);
+ }
+
+ // Reset thread-bound LocaleContext.
+ LocaleContextHolder.setLocaleContext(null);
+ }
+
}