← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18271: more support for i18n web-api translation

 

------------------------------------------------------------
revno: 18271
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-02-16 12:30:23 +0700
message:
  more support for i18n web-api translation
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java


--
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-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2015-02-16 03:56:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2015-02-16 05:30:23 +0000
@@ -338,17 +338,17 @@
         serialize( request, response, summary );
     }
 
-    protected void translate( List<T> entities, TranslateOptions translate )
+    protected void translate( List<T> entities, TranslateOptions translateOptions )
     {
-        if ( translate.isTranslate() )
+        if ( translateOptions.isTranslate() )
         {
-            if ( translate.defaultLocale() )
+            if ( translateOptions.defaultLocale() )
             {
                 i18nService.internationalise( entities );
             }
             else
             {
-                i18nService.internationalise( entities, translate.getLocale() );
+                i18nService.internationalise( entities, translateOptions.getLocale() );
             }
         }
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementGroupController.java	2015-02-16 05:30:23 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dxf2.metadata.TranslateOptions;
 import org.hisp.dhis.schema.descriptors.DataElementGroupSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.utils.ContextUtils;
@@ -67,11 +68,14 @@
     private DataElementCategoryService dataElementCategoryService;
 
     @RequestMapping( value = "/{uid}/operands", method = RequestMethod.GET )
-    public String getOperands( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
+    public String getOperands( @PathVariable( "uid" ) String uid,
+        @RequestParam Map<String, String> parameters,
+        TranslateOptions translateOptions,
         Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         WebOptions options = new WebOptions( parameters );
         List<DataElementGroup> dataElementGroups = getEntity( uid );
+        translate( dataElementGroups, translateOptions );
 
         if ( dataElementGroups.isEmpty() )
         {
@@ -109,12 +113,16 @@
     }
 
     @RequestMapping( value = "/{uid}/operands/query/{q}", method = RequestMethod.GET )
-    public String getOperandsByQuery( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
-        @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
+    public String getOperandsByQuery( @PathVariable( "uid" ) String uid,
+        @PathVariable( "q" ) String q,
+        @RequestParam Map<String, String> parameters,
+        TranslateOptions translateOptions,
+        Model model, HttpServletRequest request,
         HttpServletResponse response ) throws Exception
     {
         WebOptions options = new WebOptions( parameters );
         List<DataElementGroup> dataElementGroups = getEntity( uid );
+        translate( dataElementGroups, translateOptions );
 
         if ( dataElementGroups.isEmpty() )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2015-02-16 05:30:23 +0000
@@ -33,6 +33,7 @@
 import com.google.common.collect.Lists;
 
 import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.dxf2.metadata.TranslateOptions;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
@@ -211,12 +212,12 @@
 
     @RequestMapping( value = "/{uid}/parents", method = RequestMethod.GET )
     public List<OrganisationUnit> getEntityList( @PathVariable( "uid" ) String uid,
-        @RequestParam Map<String, String> parameters, Model model,
+        @RequestParam Map<String, String> parameters, Model model, TranslateOptions translateOptions,
         HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         OrganisationUnit organisationUnit = manager.get( getEntityClass(), uid );
-
         List<OrganisationUnit> organisationUnits = Lists.newArrayList();
+        translate( organisationUnits, translateOptions );
 
         if ( organisationUnit != null )
         {