← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1305: Included Locale in the I18nInterceptor.

 

------------------------------------------------------------
revno: 1305
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-01-12 09:46:46 +0100
message:
  Included Locale in the I18nInterceptor.
modified:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/I18nInterceptor.java
  dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/I18nInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/I18nInterceptor.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/interceptor/I18nInterceptor.java	2010-01-12 08:46:46 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 
 import ognl.NoSuchPropertyException;
@@ -36,6 +37,7 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.i18n.I18nManager;
+import org.hisp.dhis.i18n.locale.LocaleManager;
 
 import com.opensymphony.xwork2.Action;
 import com.opensymphony.xwork2.ActionInvocation;
@@ -49,8 +51,8 @@
     implements Interceptor
 {
     private static final String KEY_I18N = "i18n";
-
     private static final String KEY_I18N_FORMAT = "format";
+    private static final String KEY_LOCALE = "locale";
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -62,6 +64,13 @@
     {
         i18nManager = manager;
     }
+    
+    private LocaleManager localeManager;
+
+    public void setLocaleManager( LocaleManager localeManager )
+    {
+        this.localeManager = localeManager;
+    }
 
     // -------------------------------------------------------------------------
     // AroundInterceptor implementation
@@ -86,14 +95,16 @@
 
         I18n i18n = i18nManager.getI18n( action.getClass() );
         I18nFormat i18nFormat = i18nManager.getI18nFormat();
+        Locale locale = localeManager.getCurrentLocale();
 
         // ---------------------------------------------------------------------
         // Make the objects available for web templates
         // ---------------------------------------------------------------------
 
-        Map<String, Object> i18nMap = new HashMap<String, Object>( 2 );
+        Map<String, Object> i18nMap = new HashMap<String, Object>( 3 );
         i18nMap.put( KEY_I18N, i18n );
         i18nMap.put( KEY_I18N_FORMAT, i18nFormat );
+        i18nMap.put( KEY_LOCALE, locale );
 
         invocation.getStack().push( i18nMap );
 
@@ -118,6 +129,14 @@
         catch ( NoSuchPropertyException e )
         {
         }
+
+        try
+        {
+            Ognl.setValue( KEY_LOCALE, contextMap, action, locale );
+        }
+        catch ( NoSuchPropertyException e )
+        {
+        }
         
         return invocation.invoke();
     }

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2009-12-09 09:34:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2010-01-12 08:46:46 +0000
@@ -590,6 +590,7 @@
 
 	<bean id="org.hisp.dhis.interceptor.I18nInterceptor" class="org.hisp.dhis.interceptor.I18nInterceptor">
 		<property name="i18nManager" ref="org.hisp.dhis.i18n.I18nManager" />
+		<property name="localeManager" ref="org.hisp.dhis.i18n.locale.LocaleManager"/>
 	</bean>
 
 	<bean id="org.hisp.dhis.interceptor.SortOrderInterceptor" class="org.hisp.dhis.interceptor.SortOrderInterceptor">