dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15735
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5784: I18n db, using fixed list of locales as jdk list is unwieldy and incomplete
------------------------------------------------------------
revno: 5784
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-01-22 13:16:48 +0100
message:
I18n db, using fixed list of locales as jdk list is unwieldy and incomplete
modified:
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/resources/META-INF/dhis/beans.xml
--
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-22 09:58:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java 2012-01-22 12:16:48 +0000
@@ -33,7 +33,6 @@
import static org.hisp.dhis.system.util.ReflectionUtils.isCollection;
import static org.hisp.dhis.system.util.ReflectionUtils.setProperty;
-import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -47,6 +46,7 @@
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.common.NameableObject;
+import org.hisp.dhis.system.util.LocaleUtils;
import org.hisp.dhis.translation.Translation;
import org.hisp.dhis.translation.TranslationService;
import org.hisp.dhis.user.UserSettingService;
@@ -76,6 +76,33 @@
}
// -------------------------------------------------------------------------
+ // Properties
+ // -------------------------------------------------------------------------
+
+ private List<Locale> locales = new ArrayList<Locale>();
+
+ public void setLocales( List<String> localeStrings )
+ {
+ for ( String string : localeStrings )
+ {
+ Locale locale = LocaleUtils.getLocale( string );
+
+ if ( locale != null )
+ {
+ locales.add( locale );
+ }
+ }
+
+ Collections.sort( locales, new Comparator<Locale>()
+ {
+ public int compare( Locale l1, Locale l2 )
+ {
+ return l1.getDisplayName().compareTo( l2.getDisplayName() );
+ }
+ } );
+ }
+
+ // -------------------------------------------------------------------------
// Internationalise
// -------------------------------------------------------------------------
@@ -254,17 +281,7 @@
}
public List<Locale> getAvailableLocales()
- {
- List<Locale> locales = Arrays.asList( DateFormat.getAvailableLocales() );
-
- Collections.sort( locales, new Comparator<Locale>()
- {
- public int compare( Locale l1, Locale l2 )
- {
- return l1.getDisplayName().compareTo( l2.getDisplayName() );
- }
- } );
-
+ {
return locales;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-01-22 09:58:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-01-22 12:16:48 +0000
@@ -588,6 +588,27 @@
<bean id="org.hisp.dhis.i18n.I18nService" class="org.hisp.dhis.i18n.DefaultI18nService">
<property name="translationService" ref="org.hisp.dhis.translation.TranslationService" />
<property name="userSettingService" ref="org.hisp.dhis.user.UserSettingService" />
+ <property name="locales">
+ <list>
+ <value>af</value>
+ <value>ar</value>
+ <value>am</value>
+ <value>de</value>
+ <value>en</value>
+ <value>es</value>
+ <value>fr</value>
+ <value>gu</value>
+ <value>hi</value>
+ <value>it</value>
+ <value>ja</value>
+ <value>nl</value>
+ <value>no</value>
+ <value>pt</value>
+ <value>ru</value>
+ <value>sw</value>
+ <value>vi</value>
+ </list>
+ </property>
</bean>
<!-- Startup routine definitions -->