• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Need Help regarding Internationalization in JSF

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 90
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 90
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
What's gotten into you? Could it be this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic