← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12504: Translations, simplifications

 

------------------------------------------------------------
revno: 12504
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-08 15:47:33 +0200
message:
  Translations, simplifications
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/TranslationDeletionHandler.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/AddLocaleAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/ValidateLocaleAction.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/translation/TranslationDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/TranslationDeletionHandler.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/translation/TranslationDeletionHandler.java	2013-10-08 13:47:33 +0000
@@ -157,16 +157,6 @@
     {
         Collection<Translation> translations = translationService.getTranslations( LocaleUtils.getLocale( i18nLocale.getLocale() ) );
 
-        if ( translations.size() == 0 )
-        {
-            return null;
-        }
-        else
-        {
-            Translation translation = translations.iterator().next();
-
-            return translation.getLocale();
-        }
+        return translations.isEmpty() ? null : translations.iterator().next().getLocale();
     }
-
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/AddLocaleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/AddLocaleAction.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/AddLocaleAction.java	2013-10-08 13:47:33 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.i18n.I18nLocaleService;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -70,9 +71,8 @@
     public String execute()
         throws Exception
     {
-        // Pass 'addI18nLocale' nulls if the value is empty
-        if ( language.isEmpty() ) { language = null; }
-        if ( country.isEmpty() ) { country = null; }
+        language = StringUtils.trimToNull( language );
+        country = StringUtils.trimToNull( country );
                         
         localeService.addI18nLocale( language, country );
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/ValidateLocaleAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/ValidateLocaleAction.java	2013-10-08 13:19:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/locale/ValidateLocaleAction.java	2013-10-08 13:47:33 +0000
@@ -29,6 +29,7 @@
 
 import java.util.Locale;
 
+import org.apache.commons.lang.StringUtils;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nLocaleService;
 import org.hisp.dhis.i18n.locale.I18nLocale;
@@ -89,8 +90,9 @@
 
     public String execute()
     {
-
-        if ( localeCode != null && localeCode != "" )
+        localeCode = StringUtils.trimToNull( localeCode );
+        
+        if ( localeCode != null )
         {
             Locale locale = LocaleUtils.getLocale( localeCode );