dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40807
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20762: Short-cutting internationalization of objects if using default locale
------------------------------------------------------------
revno: 20762
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-10-19 13:25:31 +0200
message:
Short-cutting internationalization of objects if using default locale
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/locale/LocaleManager.java
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/ui/locale/UserSettingLocaleManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/resourcebundle/DefaultResourceBundleManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.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-api/src/main/java/org/hisp/dhis/i18n/locale/LocaleManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/locale/LocaleManager.java 2015-09-16 14:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/locale/LocaleManager.java 2015-10-19 11:25:31 +0000
@@ -39,7 +39,7 @@
{
String ID = LocaleManager.class.getName();
- Locale DHIS_STANDARD_LOCALE = new Locale( "en" );
+ Locale DEFAULT_LOCALE = new Locale( "en" );
Locale getCurrentLocale();
=== 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 2015-05-30 13:36:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2015-10-19 11:25:31 +0000
@@ -31,6 +31,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.i18n.locale.LocaleManager;
import org.hisp.dhis.translation.Translation;
import org.hisp.dhis.translation.TranslationService;
import org.hisp.dhis.user.UserSettingService;
@@ -78,20 +79,13 @@
}
// -------------------------------------------------------------------------
- // Internationalise
+ // I18nService implementation
// -------------------------------------------------------------------------
@Override
public void internationalise( Object object )
{
- if ( isCollection( object ) )
- {
- internationaliseCollection( (Collection<?>) object, getCurrentLocale() );
- }
- else
- {
- internationaliseObject( object, getCurrentLocale() );
- }
+ internationalise( object, getCurrentLocale() );
}
@Override
@@ -109,7 +103,7 @@
private void internationaliseObject( Object object, Locale locale )
{
- if ( locale == null || object == null )
+ if ( locale == null || object == null || locale.equals( LocaleManager.DEFAULT_LOCALE ) )
{
return;
}
@@ -134,7 +128,7 @@
private void internationaliseCollection( Collection<?> objects, Locale locale )
{
- if ( locale == null || objects == null || objects.size() == 0 )
+ if ( locale == null || objects == null || locale.equals( LocaleManager.DEFAULT_LOCALE ) || objects.size() == 0 )
{
return;
}
@@ -189,7 +183,7 @@
return null;
}
- if ( !(object instanceof IdentifiableObject) )
+ if ( !( object instanceof IdentifiableObject ) )
{
throw new IllegalArgumentException( "I18n object must be identifiable: " + object );
}
@@ -199,8 +193,8 @@
return Arrays.asList( DataElement.I18N_PROPERTIES );
}
- return (object instanceof NameableObject) ? Arrays.asList( NameableObject.I18N_PROPERTIES ) : Arrays
- .asList( IdentifiableObject.I18N_PROPERTIES );
+ return (object instanceof NameableObject) ? Arrays.asList( NameableObject.I18N_PROPERTIES ) :
+ Arrays.asList( IdentifiableObject.I18N_PROPERTIES );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/locale/UserSettingLocaleManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/locale/UserSettingLocaleManager.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/locale/UserSettingLocaleManager.java 2015-10-19 11:25:31 +0000
@@ -77,7 +77,7 @@
return locale;
}
- return DHIS_STANDARD_LOCALE;
+ return DEFAULT_LOCALE;
}
@Override
@@ -98,7 +98,7 @@
locales.add( userLocale );
}
- locales.add( DHIS_STANDARD_LOCALE );
+ locales.add( DEFAULT_LOCALE );
return locales;
}
@@ -111,7 +111,7 @@
@Override
public Locale getFallbackLocale()
{
- return DHIS_STANDARD_LOCALE;
+ return DEFAULT_LOCALE;
}
@Override
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/resourcebundle/DefaultResourceBundleManager.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/resourcebundle/DefaultResourceBundleManager.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/ui/resourcebundle/DefaultResourceBundleManager.java 2015-10-19 11:25:31 +0000
@@ -240,7 +240,7 @@
}
}
- return LocaleManager.DHIS_STANDARD_LOCALE;
+ return LocaleManager.DEFAULT_LOCALE;
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2015-10-14 09:35:22 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/message/DefaultMessageService.java 2015-10-19 11:25:31 +0000
@@ -419,7 +419,7 @@
values.put( "responseUrl", baseUrl + "/dhis-web-dashboard-integration/readMessage.action?id=" + conversation.getUid() );
- Locale locale = (Locale) userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE, LocaleManager.DHIS_STANDARD_LOCALE, conversation.getUser() );
+ Locale locale = (Locale) userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE, LocaleManager.DEFAULT_LOCALE, conversation.getUser() );
values.put( "i18n", i18nManager.getI18n( locale ) );
return new VelocityManager().render( values , MESSAGE_EMAIL_FOOTER_TEMPLATE );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2015-10-15 08:07:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/security/DefaultSecurityService.java 2015-10-19 11:25:31 +0000
@@ -238,7 +238,7 @@
vars.put( "username", credentials.getUsername() );
User user = credentials.getUserInfo();
- Locale locale = (Locale) userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE, LocaleManager.DHIS_STANDARD_LOCALE, user );
+ Locale locale = (Locale) userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE, LocaleManager.DEFAULT_LOCALE, user );
I18n i18n = i18nManager.getI18n( locale );
vars.put( "i18n", i18n );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java 2015-10-14 09:35:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/SetupTreeAction.java 2015-10-19 11:25:31 +0000
@@ -256,13 +256,13 @@
attributeValues = AttributeUtils.getAttributeValueMap( user.getAttributeValues() );
- currentLocale = (Locale) userSettingService.getUserSetting( KEY_UI_LOCALE, LocaleManager.DHIS_STANDARD_LOCALE, user );
+ currentLocale = (Locale) userSettingService.getUserSetting( KEY_UI_LOCALE, LocaleManager.DEFAULT_LOCALE, user );
currentLocaleDb = (Locale) userSettingService.getUserSetting( KEY_DB_LOCALE, null, user );
}
else
{
- currentLocale = LocaleManager.DHIS_STANDARD_LOCALE;
+ currentLocale = LocaleManager.DEFAULT_LOCALE;
}
availableLocales = localeManager.getAvailableLocales();