← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5757: WIP i18n db

 

------------------------------------------------------------
revno: 5757
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-01-19 15:20:31 +0100
message:
  WIP i18n db
removed:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/ValidateAddDuplicatedTranslationAction.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm
  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/dhis-web-commons.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm


--
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	2012-01-19 13:00:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java	2012-01-19 14:20:31 +0000
@@ -86,18 +86,22 @@
         {
             internationaliseCollection( (Collection<?>) object );
         }
-
-        internationalise( object, localeManager.getCurrentLocale() );
+        else
+        {
+            internationalise( object, localeManager.getCurrentLocale() );
+        }
     }
 
-    public void localise( Object object, Locale locale ) //TODO remove/rename?
+    public void localise( Object object, Locale locale )
     {
         if ( isCollection( object ) )
         {
             internationaliseCollection( (Collection<?>) object, locale );
         }
-
-        internationalise( object, locale );
+        else
+        {
+            internationalise( object, locale );
+        }
     }
 
     private void internationalise( Object object, Locale locale )
@@ -175,9 +179,9 @@
 
     public List<String> getTranslationProperties( Object object )
     {
-        if ( object == null || !( object instanceof IdentifiableObject ) )
+        if ( !( object instanceof IdentifiableObject ) )
         {
-            throw new IllegalArgumentException( "I18n objects must be not null and identifiable" );
+            throw new IllegalArgumentException( "I18n object must be identifiable: " + object );
         }
         
         return ( object instanceof NameableObject ) ? Arrays.asList( NameableObject.I18N_PROPERTIES ) : Arrays.asList( IdentifiableObject.I18N_PROPERTIES );        

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java	2012-01-19 14:20:31 +0000
@@ -38,6 +38,8 @@
 import static org.hisp.dhis.system.util.ReflectionUtils.setProperty;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
@@ -97,9 +99,13 @@
     @Test
     public void testIsCollection()
     {
-        List<Object> list = new ArrayList<Object>();
+        List<Object> colA = new ArrayList<Object>();
+        Collection<DataElement> colB = new HashSet<DataElement>();
+        Collection<DataElement> colC = new ArrayList<DataElement>();
         
-        assertTrue( isCollection( list ) );
+        assertTrue( isCollection( colA ) );
+        assertTrue( isCollection( colB ) );
+        assertTrue( isCollection( colC ) );
         assertFalse( isCollection( dataElementA ) );
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm	2012-01-19 11:43:06 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm	2012-01-19 14:20:31 +0000
@@ -21,8 +21,8 @@
 	<td style="width:20em">
         <select id="loc" name="loc" onchange="getTranslation()" style="min-width:20em">
             <option value="NONE">$i18n.getString( "translation_select_locale" )</option>
-			#foreach ( $locale in $availableLocales )
-				<option value="$locale" #if( $currentLocale == $locale ) selected="selected" #end>$!locale.displayName</option>
+			#foreach ( $loc in $availableLocales )
+				<option value="$loc" #if( $locale == $loc ) selected="selected" #end>$!loc.displayName</option>
 			#end
 		</select>
     </td>

=== removed file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/ValidateAddDuplicatedTranslationAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/ValidateAddDuplicatedTranslationAction.java	2012-01-19 11:43:06 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/ValidateAddDuplicatedTranslationAction.java	1970-01-01 00:00:00 +0000
@@ -1,214 +0,0 @@
-package org.hisp.dhis.i18n.action;
-
-/*
- * Copyright (c) 2004-2005, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Locale;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.i18n.I18nService;
-import org.hisp.dhis.system.util.LocaleUtils;
-import org.hisp.dhis.translation.TranslationService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Dang Duy Hieu
- * @version $Id$
- * @since 2010-03-30
- */
-public class ValidateAddDuplicatedTranslationAction
-    implements Action
-{
-    private static final Log log = LogFactory.getLog( ValidateAddDuplicatedTranslationAction.class );
-
-    private static final String PROPERTY_NAME = "name";
-
-    private static final String PROPERTY_SHORTNAME = "shortname";
-
-    private static final String WARNING_MESSAGE = "translation_duplicated_";
-
-    private String className;
-
-    private String id;
-
-    private String loc;
-
-    private String name;
-
-    private String shortName;
-
-    private String message;
-
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private I18nService i18nService;
-
-    public void setI18nService( I18nService service )
-    {
-        i18nService = service;
-    }
-
-    private TranslationService translationService;
-
-    public void setTranslationService( TranslationService translationService )
-    {
-        this.translationService = translationService;
-    }
-
-    // -------------------------------------------------------------------------
-    // I18n Object
-    // -------------------------------------------------------------------------
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input
-    // -------------------------------------------------------------------------
-
-    public void setClassName( String className )
-    {
-        this.className = className;
-    }
-
-    public void setId( String id )
-    {
-        this.id = id;
-    }
-
-    public void setLoc( String locale )
-    {
-        this.loc = locale;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public void setShortName( String shortName )
-    {
-        this.shortName = shortName;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output
-    // -------------------------------------------------------------------------
-
-    public String getMessage()
-    {
-        return message;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-        throws Exception
-    {
-        log.info( "Classname: " + className + ", id: " + id + ", loc: " + loc );
-        log.info( "name: " + name + ", shortName: " + shortName );
-
-        Locale thisLocale = LocaleUtils.getLocale( loc );
-
-        if ( name == null && shortName == null )
-        {
-            return SUCCESS;
-        }
-
-        if ( name != null )
-        {
-            name = name.trim();
-        }
-        if ( shortName != null )
-        {
-            shortName = shortName.trim();
-        }
-        if ( (name.length() == 0) && (shortName.length() == 0) )
-        {
-            return SUCCESS;
-        }
-
-        // -------------------------------------------------------------
-        // Checking duplicated name
-        // -------------------------------------------------------------
-
-        /*
-        List<String> propertyNames = i18nService.getPropertyNames( className );
-
-        for ( String propertyName : propertyNames )
-        {
-            if ( propertyName.equalsIgnoreCase( PROPERTY_NAME ) )
-            {
-                Translation objMatch = translationService.getTranslation( className, thisLocale, propertyName, name,
-                    Integer.parseInt( id ) );
-
-                if ( objMatch != null )
-                {
-                    message = i18n.getString( WARNING_MESSAGE + PROPERTY_NAME + "_with" )
-                        + " <br/><br/> <center><strong>[ " + className + " ]  -  [ "
-                        + i18n.getString( "translation_label_id" ) + ":= " + objMatch.getId() + " ]  -  [ "
-                        + i18n.getString( "translation_label_name" ) + ":= " + objMatch.getValue()
-                        + " ]</strong></center>";
-
-                    return INPUT;
-                }
-            }
-            else if ( propertyName.equalsIgnoreCase( PROPERTY_SHORTNAME ) )
-            {
-                Translation objMatch = translationService.getTranslation( className, thisLocale, propertyName,
-                    shortName, Integer.parseInt( id ) );
-
-                if ( objMatch != null )
-                {
-                    message = i18n.getString( WARNING_MESSAGE + PROPERTY_SHORTNAME + "_with" )
-                        + " <br/><br/> <center><strong>[ " + className + " ]  -  [ "
-                        + i18n.getString( "translation_label_id" ) + ":= " + objMatch.getId() + " ]  -  [ "
-                        + i18n.getString( "translation_label_short_name" ) + ":= " + objMatch.getValue()
-                        + " ]</strong></center>";
-
-                    return INPUT;
-                }
-            }
-        }
-*/
-        message = "OK";
-
-        return SUCCESS;
-    }
-
-}

=== 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	2012-01-19 11:43:06 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml	2012-01-19 14:20:31 +0000
@@ -307,15 +307,6 @@
 	</property>
   </bean>
 
-  <bean id="org.hisp.dhis.i18n.action.ValidateAddDuplicatedTranslationAction" class="org.hisp.dhis.i18n.action.ValidateAddDuplicatedTranslationAction">
-    <property name="i18nService">
-      <ref bean="org.hisp.dhis.i18n.I18nService" />
-    </property>
-    <property name="translationService">
-      <ref bean="org.hisp.dhis.translation.TranslationService" />
-    </property>
-  </bean>
-
   <!-- About -->
 
   <bean id="org.hisp.dhis.about.action.AboutAction" class="org.hisp.dhis.about.action.AboutAction" scope="prototype">

=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2011-10-03 09:50:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml	2012-01-19 14:20:31 +0000
@@ -297,14 +297,6 @@
       </result>
     </action>
 
-    <action name="validateAddDuplicatedTranslation" class="org.hisp.dhis.i18n.action.ValidateAddDuplicatedTranslationAction">
-      <result name="success" type="velocity-json">
-        /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-      <result name="input" type="velocity-json">
-        /dhis-web-commons/ajax/jsonResponseInput.vm</result>
-      <param name="onExceptionReturn">plainTextError</param>
-    </action>
-
     <action name="getTranslations" class="org.hisp.dhis.i18n.action.GetTranslationsAction">
       <result name="success" type="velocity-json">
         /dhis-web-commons/i18n/jsonTranslations.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2011-09-26 09:31:56 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2012-01-19 14:20:31 +0000
@@ -66,11 +66,11 @@
 				<tbody id="list">
 				#foreach( $dataElement in $dataElements )
 				<tr id="tr${dataElement.id}">
-					<td onclick="showDataElementDetails( $dataElement.id )">$encoder.htmlEncode( $dataElement.name )</td>
+					<td onclick="showDataElementDetails( $dataElement.id )">$encoder.htmlEncode( $dataElement.displayName )</td>
 					<td style="text-align:right">
 					  <a href="showUpdateDataElementForm.action?id=$dataElement.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a>
 					  <a href="javascript:translate( 'DataElement', '$dataElement.id' )" title="$i18n.getString( 'translation_translate' )"><img src="../images/i18n.png" alt="$i18n.getString( 'translation_translate' )"/></a>
-					  <a href="javascript:removeDataElement( $dataElement.id, '$encoder.jsEncode( $dataElement.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
+					  <a href="javascript:removeDataElement( $dataElement.id, '$encoder.jsEncode( $dataElement.displayName )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a>
 					  <a href="javascript:showDataElementDetails( $dataElement.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a>
 					</td>
 				</tr>