Hi list,
I moved all locale data into properties file now.
These files are generated by an experimental version fo gnu.localegen
part of cp-tools. The functional changes to our sources are attached.
The locale data changes is uploaded here:
http://www.kaffe.org/~mkoch/locales-data.diff.bz2
(the file is 530 kb in bzip2 format, 5.5 MB unpacked)
Please comment on the changes.
Michael
2005-05-04 Michael Koch <[EMAIL PROTECTED]>
* java/text/DateFormatSymbols.java
(getStringArray): New method.
(getZoneStrings): Likewise.
(DateFormatSymbols): Load symbols from properties files.
* java/util/Locale.java
(getDisplayLanguage): Handle new way to load language names.
(getDisplayCountry): Handle new way to load territory names.
(getDisplayVariant): Handle new way to load variant names.
* lib/Makefile.am, lib/gen-classlist.sh.in:
No need to special case classes from gnu.java.locale anymore.
* scripts/generate-locale-list.sh:
Generate list from the new properties files.
Index: java/text/DateFormatSymbols.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/DateFormatSymbols.java,v
retrieving revision 1.15
diff -u -r1.15 DateFormatSymbols.java
--- java/text/DateFormatSymbols.java 16 Feb 2005 11:18:38 -0000 1.15
+++ java/text/DateFormatSymbols.java 4 May 2005 07:14:56 -0000
@@ -41,6 +41,7 @@
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.StringTokenizer;
/**
* This class acts as container for locale specific date/time formatting
@@ -78,13 +79,62 @@
transient String[] dateFormats;
transient String[] timeFormats;
- private String[] formatsForKey(ResourceBundle res, String key)
+ private static String[] getStringArray(ResourceBundle res, String name)
+ {
+ int index = 0;
+ String data = res.getString(name);
+ StringTokenizer st = new StringTokenizer(data, "\u00ae");
+ String[] array = new String[st.countTokens()];
+
+ while (st.hasMoreTokens())
+ {
+ array[index] = st.nextToken();
+ index++;
+ }
+
+ return array;
+ }
+
+ private String[][] getZoneStrings(ResourceBundle res)
{
- String[] values = new String [formatPrefixes.length];
- for (int i = 0; i < formatPrefixes.length; i++)
+ try
+ {
+ int index = 0;
+ String data = res.getString("zoneStrings");
+ StringTokenizer st = new StringTokenizer(data, "\u00ae\u00ae");
+ String[][] array = new String[st.countTokens()][];
+
+ while (st.hasMoreTokens())
+ {
+ int index2 = 0;
+ String token = st.nextToken();
+ StringTokenizer st2 = new StringTokenizer(token, "\u00ae");
+ array[index] = new String[st2.countTokens()];
+
+ while (st2.hasMoreTokens())
+ {
+ array[index][index2] = st2.nextToken();
+ index2++;
+ }
+
+ index++;
+ }
+
+ return array;
+ }
+ catch (MissingResourceException e)
{
- values[i] = res.getString(formatPrefixes[i]+key);
+ return new String[0][];
}
+ }
+
+ private String[] formatsForKey(ResourceBundle res, String key)
+ {
+ String[] values = new String[formatPrefixes.length];
+
+ for (int i = 0; i < formatPrefixes.length; i++)
+ values[i] = res.getString(formatPrefixes[i] + key);
+
return values;
}
@@ -101,15 +151,14 @@
= ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
ClassLoader.getSystemClassLoader());
- ampms = res.getStringArray ("ampms");
- eras = res.getStringArray ("eras");
- localPatternChars = res.getString ("localPatternChars");
- months = res.getStringArray ("months");
- shortMonths = res.getStringArray ("shortMonths");
- shortWeekdays = res.getStringArray ("shortWeekdays");
- weekdays = res.getStringArray ("weekdays");
- zoneStrings = (String[][]) res.getObject ("zoneStrings");
-
+ ampms = getStringArray(res, "ampms");
+ eras = getStringArray(res, "eras");
+ localPatternChars = res.getString("localPatternChars");
+ months = getStringArray(res, "months");
+ shortMonths = getStringArray(res, "shortMonths");
+ shortWeekdays = getStringArray(res, "shortWeekdays");
+ weekdays = getStringArray(res, "weekdays");
+ zoneStrings = getZoneStrings(res);
dateFormats = formatsForKey(res, "DateFormat");
timeFormats = formatsForKey(res, "TimeFormat");
}
Index: java/util/Locale.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Locale.java,v
retrieving revision 1.27
diff -u -r1.27 Locale.java
--- java/util/Locale.java 16 Feb 2005 20:54:25 -0000 1.27
+++ java/util/Locale.java 4 May 2005 07:14:56 -0000
@@ -1,5 +1,5 @@
/* Locale.java -- i18n locales
- Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,6 @@
package java.util;
import gnu.classpath.SystemProperties;
-import gnu.java.locale.LocaleHelper;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -663,8 +662,19 @@
*/
public String getDisplayLanguage(Locale inLocale)
{
- return LocaleHelper.getLocalizedString(inLocale, language,
- "languages", true, false);
+ try
+ {
+ ResourceBundle res =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ inLocale,
+ ClassLoader.getSystemClassLoader());
+
+ return res.getString("languages." + language);
+ }
+ catch (MissingResourceException e)
+ {
+ return language;
+ }
}
/**
@@ -710,8 +720,19 @@
*/
public String getDisplayCountry(Locale inLocale)
{
- return LocaleHelper.getLocalizedString(inLocale, country,
- "territories", true, false);
+ try
+ {
+ ResourceBundle res =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ inLocale,
+ ClassLoader.getSystemClassLoader());
+
+ return res.getString("territories." + country);
+ }
+ catch (MissingResourceException e)
+ {
+ return country;
+ }
}
/**
@@ -758,8 +779,19 @@
*/
public String getDisplayVariant(Locale inLocale)
{
- return LocaleHelper.getLocalizedString(inLocale, variant, "variants",
- true, false);
+ try
+ {
+ ResourceBundle res =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ inLocale,
+ ClassLoader.getSystemClassLoader());
+
+ return res.getString("variants." + variant);
+ }
+ catch (MissingResourceException e)
+ {
+ return variant;
+ }
}
/**
Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/lib/Makefile.am,v
retrieving revision 1.80
diff -u -r1.80 Makefile.am
--- lib/Makefile.am 2 May 2005 17:15:33 -0000 1.80
+++ lib/Makefile.am 4 May 2005 07:14:56 -0000
@@ -14,12 +14,11 @@
if FOUND_GCJ
JAVAC = $(GCJ) --bootclasspath '' --classpath $(compile_classpath) -C -d .
@classes.standard \
&& $(GCJ) -Wno-deprecated --bootclasspath '' --classpath $(compile_classpath)
-C -d . @classes.awt \
-&& $(GCJ) -Wno-deprecated --bootclasspath '' --classpath $(compile_classpath)
-C -d . @classes.locale \
&& $(GCJ) -Wno-deprecated --bootclasspath '' --classpath $(compile_classpath)
-C -d . @classes.xml \
&& $(GCJ) -Wno-deprecated --bootclasspath '' --classpath $(compile_classpath)
-C -d . @classes.standardx
else
if FOUND_JIKES
-JAVAC = $(JIKES) +Pno-shadow +F -bootclasspath '' -extdirs '' -sourcepath ''
--classpath $(compile_classpath) -d . @classes
+JAVAC = $(JIKES) -nowarn +Pno-shadow +F -bootclasspath '' -extdirs ''
-sourcepath '' --classpath $(compile_classpath) -d . @classes
else
if FOUND_KJC
JAVAC = $(KJC) -classpath .:$(USER_CLASSLIB) -d . @classes
@@ -113,7 +112,7 @@
EXTRA_DIST = standard.omit mkcollections.pl.in
CLEANFILES = compile-classes resources classes \
classes.standard classes.awt classes.standardx classes.xml \
- classes.locale glibj.zip classes.1 \
+ glibj.zip classes.1 \
$(top_builddir)/java/util/LocaleData.java \
$(JAVA_DEPEND)
Index: lib/gen-classlist.sh.in
===================================================================
RCS file: /cvsroot/classpath/classpath/lib/gen-classlist.sh.in,v
retrieving revision 1.21
diff -u -r1.21 gen-classlist.sh.in
--- lib/gen-classlist.sh.in 5 Jan 2005 23:01:03 -0000 1.21
+++ lib/gen-classlist.sh.in 4 May 2005 07:14:56 -0000
@@ -38,10 +38,8 @@
# Split in multiple parts for gcj
grep -v /javax/ classes | grep -v /awt/ \
| grep -v /beans/ \
- | grep -v /locale/ \
| grep -v /xml/ > classes.standard
grep /awt/ classes > classes.awt
grep /beans/ classes >> classes.awt
-grep /locale/ classes > classes.locale
grep /xml/ classes > classes.xml
grep /javax/ classes | grep -v /xml/ > classes.standardx
Index: scripts/generate-locale-list.sh
===================================================================
RCS file: /cvsroot/classpath/classpath/scripts/generate-locale-list.sh,v
retrieving revision 1.1
diff -u -r1.1 generate-locale-list.sh
--- scripts/generate-locale-list.sh 19 Dec 2004 19:12:14 -0000 1.1
+++ scripts/generate-locale-list.sh 4 May 2005 07:14:56 -0000
@@ -5,7 +5,7 @@
cd $CLASSPATH_SRCDIR/gnu/java/locale
echo "/* LocaleData.java --"
-echo " Copyright (C) 2004 Free Software Foundation, Inc."
+echo " Copyright (C) 2004, 2005 Free Software Foundation, Inc."
echo
echo "This file is part of GNU Classpath."
echo
@@ -52,7 +52,7 @@
echo " public static String[] localeNames ="
echo " {"
-ls LocaleInformation_*.java | xargs -n 1 echo | sed -e
's/LocaleInformation_\(.*\)\.java/\1/' |
+( cd $CLASSPATH_SRCDIR/resource/gnu/java/locale ; ls LocaleInformation_*.java
) | xargs -n 1 echo | sed -e 's/LocaleInformation_\(.*\)\.java/\1/' |
while read locale ; do echo " \"$locale\"," ; done
echo " };"
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches