views:

318

answers:

4

I am staying India(has more than 20 languages) I am trying to implement java-internationalization in the website.

But in Locale.getAvailableLocales() the local languages are not available. is it possible to implement internationalization in my case?

If possible what will happen to the fonts? How am i going to load the proper fonts in the client browser?

Which framework to implement Struts or Spring?

A: 

I think you are asking multiple questions here, and they are orthogonal to each other.

For the Locale.getAvailableLocales() question. If the built-in locales are not enough, you can simply create more. The locale object just represent the locales that your program knows, it has nothing to do with you the system performs --- more specifically, no corresponding locale object does not mean you cannot support the locale.

For the font, typically you will use UTF-8 for a i18n site, so as long as your content type and charset is set properly it should render correctly in the client browser.

The framework question really depends on what you are trying to accomplish, and what do you want to gain from it.

phsiao
I think your remarks on the font are misleading; the encoding used to encode the page has little to do with the set of graphemes in the fonts available on the end-user's PC. (Using UTF-8 is a good idea, but it isn't a cure for all character issues.)
McDowell
You are right, I was over-simplifying. Using UTF-8 as your output encoding makes it work for most scenarios; however, that is assuming users have modern browsers, common fonts that you'd expect to find on the user's machines, and possible language support packs.
phsiao
@McDowell: I disagree. Anyone visiting a web site delivering, for example, Chinese characters, using a system without the fonts needed to display them installed is already dead in the water. The host can't do much more that deliver properly encoded Unicode with a proper headers for character set and content encoding. The fact is that pretty much every main-stream O/S in use today has fonts installed by default that cover every current-use language except the Asian ideographic languages; and those are usually available as a separately downloadable install due to their sheer size.
Software Monkey
A: 

I believe there are more locales available when using a JDK than a JRE.

Thorbjørn Ravn Andersen
+1  A: 

I can't claim to be an expert in Java internationalization - all of my work which cared about localization dates back to when we had to do all that by hand.

If you don't want to do that (which is no harder now than it was back then), it appears that you can still make use of Java's automated I18N services.

It appears that in order to support languages, number formats, etc, which are for locales not yet supported, you'll have to create a Locale-sensitive service provider, which got much easier in 6

There's what looks like a good tutorial here.

CPerkins
A: 

Locale.getAvailableLocales() returns a list of locales whose LocalData is installed in sun.text.resources package of JRE.

This list may not matter to you. Currently, the LocalData only contains local number and date formatting information. If you don't have any special format, you can just pick a locale whose format is the same as yours, like "en_IN".

Charset is another issue. If you localized resources are in Unicode, you are all set. Otherwise, you need to make sure the charset/encoding is supported by Java so it can convert it correctly.

Don't worry about font. It has nothing to do with server. It's either specified in HTML or CSS. As long as the browser supports the fonts, you will be fine.

Java itself is I18N ready so it doesn't matter which framework you use. Struts provides taglib for I18N (bean:message) but you can also use JSTL (fmt:message).

ZZ Coder