← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19820: Translations of variables in program indicator expression description

 

------------------------------------------------------------
revno: 19820
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-08-22 11:11:02 -0400
message:
  Translations of variables in program indicator expression description
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java	2015-08-22 15:04:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramIndicatorService.java	2015-08-22 15:11:02 +0000
@@ -48,6 +48,8 @@
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.i18n.I18nManager;
 import org.hisp.dhis.i18n.I18nService;
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.system.util.DateUtils;
@@ -58,6 +60,7 @@
 import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue;
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.google.common.collect.ImmutableMap;
@@ -145,6 +148,9 @@
     {
         this.statementBuilder = statementBuilder;
     }
+    
+    @Autowired
+    private I18nManager i18nManager;
 
     // -------------------------------------------------------------------------
     // ProgramIndicatorService implementation
@@ -268,6 +274,8 @@
             return null;
         }
         
+        I18n i18n = i18nManager.getI18n();
+        
         StringBuffer description = new StringBuffer();
 
         Matcher matcher = ProgramIndicator.EXPRESSION_PATTERN.matcher( expression );
@@ -287,7 +295,6 @@
                 if ( programStage != null && dataElement != null )
                 {
                     String programStageName = programStage.getDisplayName();
-
                     String dataelementName = dataElement.getDisplayName();
 
                     matcher.appendReplacement( description, programStageName + ProgramIndicator.SEPARATOR_ID + dataelementName );
@@ -313,25 +320,11 @@
             }
             else if ( ProgramIndicator.KEY_PROGRAM_VARIABLE.equals( key ) )
             {
-                if ( ProgramIndicator.VAR_CURRENT_DATE.equals( uid ) )
-                {
-                    matcher.appendReplacement( description, "Current date" );
-                }
-                else if ( ProgramIndicator.VAR_ENROLLMENT_DATE.equals( uid ) )
-                {
-                    matcher.appendReplacement( description, "Enrollment date" );
-                }
-                else if ( ProgramIndicator.VAR_INCIDENT_DATE.equals( uid ) )
-                {
-                    matcher.appendReplacement( description, "Incident date" );
-                }
-                else if ( ProgramIndicator.VAR_VALUE_COUNT.equals( uid ) )
-                {
-                    matcher.appendReplacement( description, "Value count" );
-                }
-                else if ( ProgramIndicator.VAR_ZERO_POS_VALUE_COUNT.equals( uid ) )
-                {
-                    matcher.appendReplacement( description, "Zero or positive value count" );
+                String varName = i18n.getString( uid );
+                
+                if ( varName != null )
+                {
+                    matcher.appendReplacement( description, varName );
                 }
             }
         }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2015-08-21 02:55:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/i18n_global.properties	2015-08-22 15:11:02 +0000
@@ -387,7 +387,7 @@
 nepali.weekday.short.saturday=Sat
 nepali.weekday.short.sunday=Sun
 
-#-- The translation page ------------------------------------------------------#
+#-- Translation page ------------------------------------------------------#
 
 translation_translate=Translate
 translation_addlocale=Add locale
@@ -993,11 +993,20 @@
 email_invite_2_2nd_paragraph=You have been sent two emails, where this is the second one. Please read the first email and follow the instructions. Please use the code below to complete the new account form.
 email_invite_2_3rd_paragraph=You must respond to this invitation within 3 months. If you take no action, the invitation will expire at that time.
 
-#-- Cache strategy display strings -------------------------------------------------------------#
+#-- Cache strategy display strings --------------------------------------------#
 
 cache_strategy=Cache strategy
 respect_system_setting=Respect system setting
 no_cache=No cache
 cache_until_6am_tomorrow=Cache until 6 AM tomorrow
 cache_for_two_weeks=Cache for two weeks
-cache_for_one_hour=Cache for one hour
\ No newline at end of file
+cache_for_one_hour=Cache for one hour
+
+#-- Program indicators --------------------------------------------------------#
+
+incident_date=Incident date
+enrollment_date=Enrollment date
+current_date=Current date
+value_count=Value count
+zero_pos_value_count=Zero or positive value count
+