From: <yos...@us...> - 2011-08-24 13:26:51
|
> Dear All, > > I am writing a utility to convert locale codes from one format to another. > > I wanted to find out if ICU4j provides similar utilities. > > To begin with my requirement is to convert :- > 1> ISO639 2 letter code to UTS35 and viceversa. I do not understand this. ISO639 2 letter code is used by UTS35, so why do you need to convert them? > 2> Java locales to UTS35 and vice versa. I assume you want traditional UTS35 format - like "ja_JP@calendar=japanese" Java Locale to UTS35: ULocale.forLocale(locale).toString() UTS35 to Java Locale: new ULocale(uts35).toLocale() The modern UTS35 locale identifier uses BCP47 format, such as "ja-JP-u-ca-japanese". If you want the modern format, then use ULocale#toLanguageTag() instead of ULocale#toString(). > 3> RFC4646 to UTS35 and viceversa. BCP47 to UTS35: ULocale.forLanguageTag(bcp47).toString() UTS35 to BCP47: new ULocale(uts35).toLanguageTag() > > Also if there are any other utilities to do the same in CLDR, Apache > or any other place, please point me to the same. I do not know if there are any. -Yoshito |