← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2916: Fixed some duplication of code introduced in DefaultI18nService

 

------------------------------------------------------------
revno: 2916
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-02-25 00:20:10 +0100
message:
  Fixed some duplication of code introduced in DefaultI18nService
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java	2011-02-24 23:14:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java	2011-02-24 23:20:10 +0000
@@ -151,55 +151,7 @@
 
     private void internationaliseCollection( Collection<?> intObjects )
     {
-        if ( intObjects == null || intObjects.size() == 0 )
-        {
-            return;
-        }
-
-        I18nObject i18nObject = isI18nObject( intObjects.iterator().next() );
-
-        Locale locale = localeManager.getCurrentLocale();
-
-        if ( i18nObject != null && locale != null )
-        {
-            Collection<Translation> allTranslations = translationService.getTranslations( i18nObject.getClassName(),
-                locale );
-
-            Collection<Translation> fallbackTranslations = null; // Not initialized unless needed
-            Map<String, String> fallbackTranslationsMap = null; // Not initialized unless needed
-
-            for ( Object object : intObjects )
-            {
-                Map<String, String> translations = getTranslationsForObject( allTranslations, getId( object ) );
-                for ( Map.Entry<String, String> translation : translations.entrySet() )
-                {
-                    String property = translation.getKey();
-                    String value = translation.getValue();
-
-                    if ( value != null && !value.isEmpty() )
-                    {
-                        setProperty( object, property, value );
-                    }
-                    else
-                    {
-                        if ( fallbackTranslations == null )
-                        {
-                            fallbackTranslations = translationService.getTranslations( i18nObject.getClassName(),
-                                locale );
-
-                            fallbackTranslationsMap = getTranslationsForObject( fallbackTranslations, getId( object ) );
-                        }
-
-                        value = fallbackTranslationsMap.get( property );
-
-                        if ( value != null && !value.isEmpty() )
-                        {
-                            setProperty( object, property, value );
-                        }
-                    }
-                }
-            }
-        }
+        internationaliseCollection( intObjects, localeManager.getCurrentLocale() );
     }
     
     private void internationaliseCollection( Collection<?> intObjects, Locale locale )
@@ -211,8 +163,6 @@
 
         I18nObject i18nObject = isI18nObject( intObjects.iterator().next() );
 
-        //Locale locale = localeManager.getCurrentLocale();
-
         if ( i18nObject != null && locale != null )
         {
             Collection<Translation> allTranslations = translationService.getTranslations( i18nObject.getClassName(),