Add support for DateFormat for a new locale
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, September 15, 2004 10:56 AM

I am looking into how to use locale for galician language formating dates (the language code is gl, at Spain ES gl_ES). In JSDK 1.4.1 all language version does not include the "gl" locale. We are developing a internationalized web aplication using JSP and Jakarta-JSTL, and when we use the fmt:formatDate tag, we get the english format (the default locale). The same if I use the DateFormat.getDateInstance(...). Is there any way to add (or register) a new locale to JSDK or JRE? can someone point me in the right direction that I can learn how to add new locale to jSDK or JRE? If I can't, where can I request to add the "gl" locale into the JRE? The gl locale is very very si   More>>

I am looking into how to use locale for galician language formating dates (the language code is gl, at Spain ES gl_ES). In JSDK 1.4.1 all language version does not include the "gl" locale.



We are developing a internationalized web aplication using JSP and Jakarta-JSTL, and when we use the fmt:formatDate tag, we get the english format (the default locale). The same if I use the DateFormat.getDateInstance(...).



Is there any way to add (or register) a new locale to JSDK or JRE? can someone point me in the right direction that I can learn how to add new locale to jSDK or JRE?



If I can't, where can I request to add the "gl" locale into the JRE? The gl locale is very very similar to "es" locale: the only difference is the name of months.



Thank you!

   <<Less

Re: Add support for DateFormat for a new locale

Posted By:   Anonymous  
Posted On:   Friday, September 17, 2004 08:19 AM

I've been investigating, and finally I found a sollution. Add a new locale is possible, and this works with jre 1.4.2, and probably other:


  1. Search in inet (google) the code for the classes
    LocaleElements_es.java and DateFormatZoneData_es.java (_es or other). I don't paste the url where I've found it to avoid problems with licenses.


  2. Rename the classes to your locale id and translate the content of LocaleElements_${LOCALE}.java. The classes MUST be in the sun.text.resources package.


  3. compile and create a jar with them


  4. copy the jar to the ${JAVA_HOME}/jre/lib/ext. The same where the localedata.jar is located. It MUST be that directory.



And it works!! :)



Anyway, Sun should add the locale, or provide an API to register new locales.

About | Sitemap | Contact