<i18n dev> How to get ResourceBundle from LocaleData
Sean Chou
zhouyx at linux.vnet.ibm.com
Mon Aug 27 23:17:55 PDT 2012
Hi Masayoshi,
It is about adding Currency variants to Slovenia . We hope there is a
method to get the currency symbol before it joins European Union. As
described in test attached. I ported a patch to openjdk 2 weeks ago, which
contains following modification:
///////////////////////////////////////////
diff -r e7d125f2575b src/share/classes/java/util/Currency.java
--- a/src/share/classes/java/util/Currency.java Sun Aug 12 22:56:45 2012
+0100
+++ b/src/share/classes/java/util/Currency.java Thu Aug 16 11:05:57 2012
+0800
@@ -352,6 +352,20 @@
*/
public static Currency getInstance(Locale locale) {
String country = locale.getCountry();
+ String variant = locale.getVariant();
+ if ("EURO".equals(variant))
+ return getInstance("EUR");
+ if ("PREEURO".equals(variant)) {
+ /* getNumberFormatData(locale) is used here to get the
FormatData's
+ * resource bundle from which the value of the Currency
property can
+ * be retrieved. getNumberFormatData(locale) is not specific to
+ * NumberFormat. It returns the FormatData's resource bundle
for the
+ * given locale and so is used here. */
+ ResourceBundle rb = LocaleData.getNumberFormatData(locale);
+ String CurrencyCode = rb.getString("Currency");
+ return getInstance(CurrencyCode);
+ }
+
if (country == null) {
throw new NullPointerException();
}
///////////////////////////////////////////
And it came across RFE: Locale Data Deployment Enhancements . So, how can
I make it work again ? And by the way, how do you think about adding this
variants to openjdk ?
On Tue, Aug 28, 2012 at 11:50 AM, Masayoshi Okutsu <
masayoshi.okutsu at oracle.com> wrote:
> Hi Sean,
>
> LocaleData is a sun private class. It was changed to support different
> locale data sources, such as the platform locale data and CLDR. Please use
> the public APIs, such as DecimalFormatSymbols, to get locale-dependent
> resources. We may change the LocaleData and its related classes further.
>
> Is there any reason that you need to use LocaleData?
>
> Thanks,
> Masayoshi
>
>
> On 8/28/2012 12:39 PM, Sean Chou wrote:
>
>> Hello ,
>>
>> I noticed that LocaleData class changed a lot static methods to
>> instance methods. I have a simple question about how to rewrite this
>> invocation: "ResourceBundle rb = LocaleData.**getNumberFormatData(locale);'
>> .
>> Thanks in advance.
>>
>>
>
--
Best Regards,
Sean Chou
More information about the i18n-dev
mailing list