Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set locale(Language support) in java

Tags:

java

locale

The inbuilt java supports only for few languages.I want to use Sinhala language as locale in my jTextPane in java programme.How can i do this ?.Pls help me...

like image 471
Thusitha Avatar asked Mar 06 '26 14:03

Thusitha


2 Answers

AFAIK inbuilt Java supports it. Just create locale: Locale locale = new Locale("si", "LK"); (si for Sinhala and LK for Sri Lanka). A corresponding bundle could be for example messages_si_LK.properties. You can also use a language code alone. Then: Locale locale = new Locale("si"); and file messages_si.properties. And you have to take care of fonts.

like image 175
zacheusz Avatar answered Mar 09 '26 04:03

zacheusz


The ICU project has extended the Java core libraries' locale support. They incorporate a much more expansive database of locale info and I believe they cover Sinhalese as the "si" locale.

ICU4J is the acronym for ICU's java specific stuff. ICU4J = ICU for java. The "Why use ICU4J?" part of their FAQ says

Locale data coverage - much better, many more locales, up-to-date

And it looks like their recent releases have expanded support for Sinhala in particular. From the 3.6 release notes

Layout: The font layout engine has support added for Tibetan, Sinhala and Old Hangul.

like image 23
Mike Samuel Avatar answered Mar 09 '26 03:03

Mike Samuel