aspose file tools*
The moose likes JSF and the fly likes Need Help regarding Internationalization in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Need Help regarding Internationalization in JSF" Watch "Need Help regarding Internationalization in JSF" New topic
Author

Need Help regarding Internationalization in JSF

Vinodh Sa
Ranch Hand

Joined: May 06, 2010
Posts: 55
Hi All,

We are going to implement our website in some other different languages (chinese, french, spanish & Korean). Currently our website is in english only. And we are planning to change all the static text and labels using the application properties (as that is the standard way of doing) through Message Bundle.
We are creating 4 different applicaiton_xx.properties file, and based on the locale, the property file will be picked.

The problem i m facing is in regard with the encoding standard used for the jsp and propertye file. I have changed both the encoding format to UTF-8. Now i m able to save the chinese/korean characters in my properties file. But when it gets rendered in JSP at runtime, the characters are not getting rendered properly. At the same time, when i hardcode the characters in my jsp directly, then i m getting the characters without any problem in my website.

The problem might be somewhere the encoding needs to be changed, which is picking the text from properties file. I have read in some sites that some encoding parameters in server side needs to be changed. Can some one help me regarding with this ?

FYI : We are using BEA Weblogic Server 9.2.


Thanks, Vinodh
[Servlet tutorial]
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Vinodh

When you're using properties files to support different languages, you need to know that Message Bundle files (properties files) are not encoded in UTF-8. Instead, Unicode characters beyond 127 are encoded as \uxxxx escape sequences. The Java SDK utility native2ascii can create these files.

Regards

Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Vinodh Sa
Ranch Hand

Joined: May 06, 2010
Posts: 55
Cesar Loachamin wrote:Hi Vinodh

When you're using properties files to support different languages, you need to know that Message Bundle files (properties files) are not encoded in UTF-8. Instead, Unicode characters beyond 127 are encoded as \uxxxx escape sequences. The Java SDK utility native2ascii can create these files.

Regards

Cesar


Thanks Cesar !!! That helped.... i found the Java utility for converting my property file into the Unicode escape characters. But apart from this isn't there no other way of doing it, i mean like we will type the characters directly in the property file and they ll be converted at run time in the server while sending the response to the client machine? And i also want to know abt why is it so ? Can you explain a bit in detail ?
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi Vinodh

With regards to your question, JSF like other java program use the java.util.Properties for internationalization, you can look into the API documentation of the load method of the java.util.Properties class for a precise description of the file format. java.util.Properties API Documentation.
And in this article you can find you're answer of why and other important things about Resource Bundles Localization with ResourceBundles, says
You must create your properties files in ASCII, or use Unicode escape codes to represent Unicode characters. Since you don't compile a property file to byte codes, there is no way to tell the Java Virtual Machine (JVM) which character set to use. So you must explicitly stick with ASCII or use the escape sequences.

And use Resource Bundles is the best way to do this, you can do this by your way but you need to obtain the current Locale, whith the Locale you need to load the correct propertie file and enconded correctly and use a application bean to set the message that you load. And really is best to use resource bundles.

Regards

Cesar

Vinodh Sa
Ranch Hand

Joined: May 06, 2010
Posts: 55
Cesar Loachamin wrote:Hi Vinodh

With regards to your question, JSF like other java program use the java.util.Properties for internationalization, you can look into the API documentation of the load method of the java.util.Properties class for a precise description of the file format. java.util.Properties API Documentation.
And in this article you can find you're answer of why and other important things about Resource Bundles Localization with ResourceBundles, says
You must create your properties files in ASCII, or use Unicode escape codes to represent Unicode characters. Since you don't compile a property file to byte codes, there is no way to tell the Java Virtual Machine (JVM) which character set to use. So you must explicitly stick with ASCII or use the escape sequences.

And use Resource Bundles is the best way to do this, you can do this by your way but you need to obtain the current Locale, whith the Locale you need to load the correct propertie file and enconded correctly and use a application bean to set the message that you load. And really is best to use resource bundles.

Regards

Cesar



Thanks Cesar !!!
I will check the API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help regarding Internationalization in JSF
 
Similar Threads
Using UTF-8 encoding for jsp textarea field instead HTML encoding
internationalization for japanese text
multiple language support in one XML
Multilingual JSP Problem
Encoding issue with Chinese and Japanese characters but not for Korean