dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02674
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 901: Fixed logical bug in Translation module and a little of bit modification in Organisation Unit Man...
------------------------------------------------------------
revno: 901
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-10-23 12:41:15 +0700
message:
Fixed logical bug in Translation module and a little of bit modification in Organisation Unit Management module
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/I18nService.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java
dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/impl/DefaultTranslationService.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.js
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/java/org/hisp/dhis/i18n/action/I18nAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitListAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnit.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-api/src/main/java/org/hisp/dhis/translation/TranslationService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationService.java 2009-10-23 05:41:15 +0000
@@ -33,11 +33,13 @@
/**
* @author Lars Helge Overland
* @version $Id$
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-23
*/
public interface TranslationService
{
String ID = TranslationService.class.getName();
-
+
Translation getTranslation( String className, int id, Locale locale, String property );
Collection<Translation> getTranslations( String className, int id, Locale locale );
@@ -55,4 +57,7 @@
Collection<Locale> getAvailableLocales();
void deleteTranslations( String className, int id );
+
+ // -------------------------------------------------------------------------
+ Collection<Translation> getTranslations( String className, String propertyName, Locale locate );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/translation/TranslationStore.java 2009-10-23 05:41:15 +0000
@@ -32,6 +32,8 @@
/**
* @author Oyvind Brucker
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-23
*/
public interface TranslationStore
{
@@ -54,4 +56,7 @@
Collection<Locale> getAvailableLocales();
void deleteTranslations( String className, int id );
+
+ // -------------------------------------------------------------------------
+ Collection<Translation> getTranslations( String className, String propertyName, Locale locate );
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2009-10-23 05:41:15 +0000
@@ -44,6 +44,8 @@
/**
* @author Oyvind Brucker
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-23
*/
public class DefaultI18nService
implements I18nService
@@ -93,8 +95,11 @@
getId( object ), locale );
Map<String, String> translationsCurrentLocale = convertTranslations( translations );
-
- Collection<Translation> translationsFallback = null; // Dont initiate unless needed
+
+ Collection<Translation> translationsFallback = null; // Dont
+ // initiate
+ // unless
+ // needed
Map<String, String> translationsFallbackLocale = null;
List<String> propertyNames = i18nObject.getPropertyNames();
@@ -139,7 +144,7 @@
Locale locale = null;
locale = localeManager.getCurrentLocale();
-
+
if ( locale == null )
{
log.error( "Unable to get current locale" );
@@ -160,10 +165,10 @@
}
/**
- * Check if all objects are of the same type, in as good
- * as all cases this will be true so we use the optimized query for that.
+ * Check if all objects are of the same type, in as good as all cases
+ * this will be true so we use the optimized query for that.
*/
-
+
boolean oneType = true;
Class<?> type = null;
@@ -197,15 +202,18 @@
{
Collection<Translation> allTranslations = translationService.getTranslations( i18nObject
.getClassName(), locale );
-
- Collection<Translation> fallbackTranslations = null; // Don't initiate unless needed
+
+ Collection<Translation> fallbackTranslations = null; // Don't
+ // initiate
+ // unless
+ // needed
Map<String, String> fallbackTranslationsMap = null;
for ( Object object : intObjects )
{
Map<String, String> translations = getTranslationsForObject( allTranslations, getId( object ) );
- for ( Map.Entry<String,String> translation : translations.entrySet() )
+ for ( Map.Entry<String, String> translation : translations.entrySet() )
{
String property = translation.getKey();
String value = translation.getValue();
@@ -218,8 +226,8 @@
{
if ( fallbackTranslations == null )
{
- fallbackTranslations = translationService.getTranslations( i18nObject.getClassName(),
- locale );
+ fallbackTranslations = translationService.getTranslations( i18nObject
+ .getClassName(), locale );
fallbackTranslationsMap = getTranslationsForObject( fallbackTranslations,
getId( object ) );
@@ -281,7 +289,7 @@
public void updateTranslation( String className, int id, Locale locale, Map<String, String> translations )
{
- for ( Map.Entry<String,String> translationEntry : translations.entrySet() )
+ for ( Map.Entry<String, String> translationEntry : translations.entrySet() )
{
String key = translationEntry.getKey();
String value = translationEntry.getValue();
@@ -289,7 +297,7 @@
if ( value != null && value.trim().length() > 0 )
{
Translation translation = translationService.getTranslation( className, id, locale, key );
-
+
if ( translation != null )
{
translation.setValue( value );
@@ -343,7 +351,7 @@
/**
* Set properties to properties from the fallback locale
*/
-
+
if ( !locale.equals( localeManager.getFallbackLocale() ) )
{
internationalise( object, localeManager.getFallbackLocale() );
@@ -463,9 +471,9 @@
/**
* Returns property/value pairs of translations for one object matching id.
- *
+ *
* @param translations Collection to search
- * @param id Object id
+ * @param id Object id
* @return Map of property/value pairs
*/
private Map<String, String> getTranslationsForObject( Collection<Translation> translations, int id )
@@ -485,10 +493,28 @@
/**
* Returns property/value pairs of a collection of translations as a map
- *
+ *
* @param translations
* @return Map containing translations
*/
+
+ // private Map<String, String> convertTranslations( Collection<Translation>
+ // translations )
+ // {
+ // Map<String, String> translationMap = new Hashtable<String, String>();
+ //
+ // for ( Translation translation : translations )
+ // {
+ // if ( translation.getProperty() != null && translation.getValue() != null
+ // )
+ // {
+ // translationMap.put( translation.getProperty(), translation.getValue() );
+ // }
+ // }
+ //
+ // return translationMap;
+ // }
+
private Map<String, String> convertTranslations( Collection<Translation> translations )
{
Map<String, String> translationMap = new Hashtable<String, String>();
@@ -497,19 +523,20 @@
{
if ( translation.getProperty() != null && translation.getValue() != null )
{
- translationMap.put( translation.getProperty(), translation.getValue() );
+ translationMap.put( translation.getId() + "_" + translation.getProperty(), translation.getValue() );
}
}
return translationMap;
}
+
/**
* Sets a property for the supplied object
- *
+ *
* @param object Object to modify
- * @param name Name of property to set
- * @param value Value the property will be set to
+ * @param name Name of property to set
+ * @param value Value the property will be set to
*/
private void setProperty( Object object, String name, String value )
{
@@ -550,7 +577,7 @@
/**
* Fetch a property off the object using reflection
- *
+ *
* @param object Object to search
* @param property Name of the property to get
* @return the value of the property or null
@@ -590,7 +617,7 @@
/**
* Returns the name of the class that the object is an instance of
* org.hisp.dhis.indicator.Indicactor returns Indicator
- *
+ *
* @param object Object to determine className of
* @return String containing the class name
*/
@@ -605,8 +632,9 @@
/**
* Calls the method getId for this object, throws exception if this fails.
- *
- * @param object object to call method on, needs to have the public method getId():int
+ *
+ * @param object object to call method on, needs to have the public method
+ * getId():int
* @return The id
*/
private int getId( Object object )
@@ -640,9 +668,9 @@
}
/**
- * Converts the property to a i18n keystring
- * alternativeName produces alternative_name
- *
+ * Converts the property to a i18n keystring alternativeName produces
+ * alternative_name
+ *
* @param propName string to parse
* @return Modified string
*/
@@ -669,7 +697,7 @@
/**
* Test if an object is enabled for i18n
- *
+ *
* @param object Object to check
* @return true if the object is enabled for i18n
*/
@@ -685,4 +713,19 @@
return false;
}
+
+ // -------------------------------------------------------------------------
+ public Map<String, String> getTranslations( String className, Locale locale )
+ {
+ Collection<Translation> translationsCol = translationService.getTranslations( className, locale );
+
+ return convertTranslations( translationsCol );
+ }
+
+ public Map<String, String> getTranslations( String className, String propertyName, Locale locate )
+ {
+ Collection<Translation> translationCol = translationService.getTranslations( className, propertyName, locate );
+
+ return convertTranslations( translationCol );
+ }
}
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/I18nService.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/I18nService.java 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/i18n/I18nService.java 2009-10-23 05:41:15 +0000
@@ -59,9 +59,14 @@
public void setToFallback( Object object );
- public void verify(Object object);
+ public void verify( Object object );
public void verifyCollection( Collection<?> collection );
public void removeObject( Object object );
+
+ // /////////////////////////////////
+ public Map<String, String> getTranslations( String className, Locale locale );
+
+ public Map<String, String> getTranslations( String className, String propertyName, Locale locate );
}
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/hibernate/HibernateTranslationStore.java 2009-10-23 05:41:15 +0000
@@ -42,6 +42,8 @@
/**
* @author Oyvind Brucker
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-23
*/
public class HibernateTranslationStore
implements TranslationStore
@@ -101,7 +103,7 @@
criteria.add( Restrictions.eq( "locale", locale.toString() ) );
criteria.setCacheable( true );
-
+
return criteria.list();
}
@@ -179,7 +181,7 @@
/**
* Creates a Locale object based on the input String
- *
+ *
* @param localestr String to parse
* @return A locale object or null if not valid
*/
@@ -208,4 +210,19 @@
return thisLocale;
}
+
+ // -------------------------------------------------------------------------
+ @SuppressWarnings( "unchecked" )
+ public Collection<Translation> getTranslations( String className, String propertyName, Locale locate )
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( Translation.class );
+
+ criteria.add( Restrictions.eq( "className", className ) );
+ criteria.add( Restrictions.eq( "property", propertyName ) );
+ criteria.add( Restrictions.eq( "locale", locate.toString() ) );
+
+ return criteria.list();
+ }
}
=== modified file 'dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/impl/DefaultTranslationService.java'
--- dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/impl/DefaultTranslationService.java 2009-06-18 12:45:22 +0000
+++ dhis-2/dhis-i18n/dhis-i18n-db/src/main/java/org/hisp/dhis/translation/impl/DefaultTranslationService.java 2009-10-23 05:41:15 +0000
@@ -38,6 +38,8 @@
/**
* @author Lars Helge Overland
* @version $Id$
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-23
*/
@Transactional
public class DefaultTranslationService
@@ -49,7 +51,7 @@
{
this.translationStore = translationStore;
}
-
+
public Translation getTranslation( String className, int id, Locale locale, String property )
{
return translationStore.getTranslation( className, id, locale, property );
@@ -94,4 +96,10 @@
{
translationStore.deleteTranslations( className, id );
}
+
+ // -------------------------------------------------------------------------
+ public Collection<Translation> getTranslations( String className, String propertyName, Locale locate )
+ {
+ return translationStore.getTranslations( className, propertyName, locate );
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.js 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/i18n.js 2009-10-23 05:41:15 +0000
@@ -37,7 +37,7 @@
var value = translations[ i ].getElementsByTagName("value")[0].firstChild.nodeValue;
- var field = document.getElementById(key);
+ var field = document.getElementById( key.split("_")[1] );
if ( field != null )
{
@@ -85,7 +85,7 @@
var value = translations[ i ].getElementsByTagName("value")[0].firstChild.nodeValue;
- var field = document.getElementById(key + " Ref");
+ var field = document.getElementById( key.split("_")[1] + " Ref");
if ( field != null )
{
=== 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 2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/i18n/translate.vm 2009-10-23 05:41:15 +0000
@@ -35,9 +35,10 @@
#foreach ( $propertyName in $propertyNames )
<tr>
#set ($prop = $propertyNamesLabel.get( $propertyName ))
+ #set ($key = $objectId + "_" + $propertyName)
<td style="width:10em"><label for="$propertyName" style="width:20em">$i18n.getString( "translation_label_$prop" ) </label></td>
- <td><input type="text" id="$propertyName" name="$propertyName" value="$encoder.htmlEncode( $translations.get( $propertyName ) )" style="width:20em"></td>
- <td><span id="$propertyName Ref" name="$propertyName Ref" style="width:20em">$encoder.htmlEncode( $referenceTranslations.get( $propertyName ) )</span></td>
+ <td><input type="text" id="$propertyName" name="$propertyName" value="$!encoder.htmlEncode( $translations.get( $key ) )" style="width:20em"></td>
+ <td><span id="$propertyName Ref" name="$propertyName Ref" style="width:20em">$!encoder.htmlEncode( $referenceTranslations.get( $key ) )</span></td>
</tr>
#end
<tr>
@@ -75,7 +76,7 @@
var propNames = new Array()
#set( $count = 0 )
#foreach ($propertyName in $propertyNames )
- propNames[$count] = "$propertyName";
+ propNames[$count] = $objectId + "_" + "$propertyName";
#set( $count = $count + 1 )
#end
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java 2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/i18n/action/I18nAction.java 2009-10-23 05:41:15 +0000
@@ -41,7 +41,7 @@
/**
* @author Oyvind Brucker
*/
-public class I18nAction
+public class I18nAction
implements Action
{
private String className;
@@ -107,7 +107,6 @@
return objectId;
}
-
public String getReturnUrl()
{
return returnUrl;
@@ -160,8 +159,8 @@
translations = i18nService.getTranslations( className, Integer.parseInt( objectId ), getCurrentLocale() );
- referenceTranslations =
- i18nService.getTranslations( className, Integer.parseInt( objectId ), getCurrentRefLocale() );
+ referenceTranslations = i18nService.getTranslations( className, Integer.parseInt( objectId ),
+ getCurrentRefLocale() );
/**
* Fill in empty strings for null values
@@ -169,16 +168,16 @@
for ( String property : getPropertyNames() )
{
- if ( translations.get( property ) == null )
+ if ( translations.get( String.valueOf( objectId ) + "_" + property ) == null )
{
- translations.put( property, "" );
+ translations.put( String.valueOf( objectId ) + "_" + property, "" );
}
- if ( referenceTranslations.get( property ) == null )
+ if ( referenceTranslations.get( String.valueOf( objectId ) + "_" + property ) == null )
{
- referenceTranslations.put( property, "" );
+ referenceTranslations.put( String.valueOf( objectId ) + "_" + property, "" );
}
}
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitListAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitListAction.java 2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/GetOrganisationUnitListAction.java 2009-10-23 05:41:15 +0000
@@ -31,8 +31,13 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import org.hisp.dhis.i18n.I18nService;
+import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
@@ -41,7 +46,10 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: GetOrganisationUnitListAction.java 1898 2006-09-22 12:06:56Z torgeilo $
+ * @version $Id: GetOrganisationUnitListAction.java 1898 2006-09-22 12:06:56Z
+ * torgeilo $
+ * @modifier Dang Duy Hieu
+ * @since 2009-10-20
*/
public class GetOrganisationUnitListAction
extends ActionSupport
@@ -50,6 +58,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static String TRANSLATION_PROPERTY_NAME = "name";
+
private OrganisationUnitSelectionManager selectionManager;
public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
@@ -57,6 +72,20 @@
this.selectionManager = selectionManager;
}
+ private LocaleManager localeManager;
+
+ public void setLocaleManager( LocaleManager localeManager )
+ {
+ this.localeManager = localeManager;
+ }
+
+ private I18nService i18nService;
+
+ public void setI18nService( I18nService service )
+ {
+ i18nService = service;
+ }
+
// -------------------------------------------------------------------------
// Comparator
// -------------------------------------------------------------------------
@@ -67,7 +96,7 @@
{
this.organisationUnitComparator = organisationUnitComparator;
}
-
+
// -------------------------------------------------------------------------
// DisplayPropertyHandler
// -------------------------------------------------------------------------
@@ -77,8 +106,8 @@
public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
{
this.displayPropertyHandler = displayPropertyHandler;
- }
-
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -90,6 +119,25 @@
return organisationUnits;
}
+ private List<String> getPropertyNames()
+ {
+ return i18nService.getPropertyNames( OrganisationUnit.class.getSimpleName() );
+ }
+
+ private Map<String, String> translationsOrgUnit = new HashMap<String, String>();
+
+ public Map<String, String> getTranslationsOrgUnit()
+ {
+ return translationsOrgUnit;
+ }
+
+ private Map<String, String> refTranslationOrgUnit = new HashMap<String, String>();
+
+ public Map<String, String> getRefTranslationOrgUnit()
+ {
+ return refTranslationOrgUnit;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -97,6 +145,7 @@
public String execute()
throws Exception
{
+
Collection<OrganisationUnit> selectedUnits = selectionManager.getSelectedOrganisationUnits();
if ( selectedUnits.isEmpty() )
@@ -110,11 +159,50 @@
organisationUnits.addAll( selectedUnit.getChildren() );
}
}
-
+
Collections.sort( organisationUnits, organisationUnitComparator );
-
+
displayPropertyHandler.handle( organisationUnits );
-
+
+ translationsOrgUnit = i18nService.getTranslations( OrganisationUnit.class.getSimpleName(),
+ TRANSLATION_PROPERTY_NAME, getCurrentLocale() );
+ refTranslationOrgUnit = i18nService.getTranslations( OrganisationUnit.class.getSimpleName(),
+ TRANSLATION_PROPERTY_NAME, getCurrentRefLocale() );
+
+ /**
+ * Fill in empty strings for null values
+ */
+
+ for ( OrganisationUnit o : organisationUnits )
+ {
+ for ( String property : getPropertyNames() )
+ {
+ if ( translationsOrgUnit.get( String.valueOf( o.getId() ) + "_" + property ) == null )
+ {
+ translationsOrgUnit.put( String.valueOf( o.getId() ) + "_" + property, "" );
+ }
+ if ( refTranslationOrgUnit.get( String.valueOf( o.getId() ) + "_" + property ) == null )
+ {
+ refTranslationOrgUnit.put( String.valueOf( o.getId() ) + "_" + property, "" );
+ }
+ }
+ }
+
return SUCCESS;
}
+
+ // -------------------------------------------------------------------------
+ // Supporting method
+ // -------------------------------------------------------------------------
+
+ private Locale getCurrentLocale()
+ {
+ return localeManager.getCurrentLocale();
+ }
+
+ private Locale getCurrentRefLocale()
+ {
+ return localeManager.getFallbackLocale();
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2009-09-09 06:36:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2009-10-23 05:41:15 +0000
@@ -15,6 +15,12 @@
<property name="selectionManager">
<ref bean="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager"/>
</property>
+ <property name="i18nService">
+ <ref bean="org.hisp.dhis.i18n.I18nService"/>
+ </property>
+ <property name="localeManager">
+ <ref bean="org.hisp.dhis.i18n.locale.LocaleManager"/>
+ </property>
</bean>
<bean id="org.hisp.dhis.oum.action.organisationunit.GetOrganisationUnitAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnit.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnit.vm 2009-05-20 11:38:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnit.vm 2009-10-23 05:41:15 +0000
@@ -20,9 +20,18 @@
<th colspan="4">$i18n.getString( "operations" )</th>
</tr>
#set( $mark = false )
+
#foreach( $organisationUnit in $organisationUnits )
+ #set( $key = $organisationUnit.getId() + "_" + "name" )
+ #set( $value = $encoder.htmlEncode($translationsOrgUnit.get($key)) )
<tr>
- <td#alternate( $mark )>$encoder.htmlEncode( $organisationUnit.name )</td>
+ <td #alternate( $mark )>
+ #if( $value != "" )
+ $value
+ #else
+ $encoder.htmlEncode( $organisationUnit.name )
+ #end
+ </td>
<td style="text-align:center"#alternate( $mark )><a href="showUpdateOrganisationUnitForm.action?id=$organisationUnit.id" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a></td>
<td style="text-align:center"#alternate( $mark )><a href="$i18n.getString( "translation_translate" )" title="$i18n.getString( "translation_translate" )" onclick="this.href='javascript:location.href= \'../dhis-web-commons/i18n.action?className=OrganisationUnit&objectId=$organisationUnit.id&returnUrl=\' + location.href'"><img src="../images/i18n.png" alt="$i18n.getString( "translation_translate" )"></a></td>
<td style="text-align:center"#alternate( $mark )>#if( $organisationUnit.children.size() == 0 )<a href="javascript:removeOrganisationUnit( $organisationUnit.id, '$encoder.jsEncode( $organisationUnit.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>#end</td>