Wednesday Feb 11, 2009

Web Space Server - Localization

We are back after hectic one month or so ... It was one of the interesting and challenging period ... So much of excitement so much to do less time .. pressure ... etc etc ... But but , Finally its out .. On Time ... Leaving behind happy faces :-).

Yeah , I'm talking about  Sun Glassfish Web Space Server 10.0 release (derived from Liferay 5.2) , first release from Sun  after one of the unique development relationship between Sun and Liferay .

 To get more details .. Refer this blog on Portal Post .

Download link.

Let move to topic of blog i.e Localization (L10n).

FAQ 1.0 : How can I get localized version Web Space Server ?

To simplify customer experience , there is not extra steps to get localized version. It has been bundled in by default. So when you download install Web Space Server , You by default get localization support.

FAQ 2.0 : In which languages Web Space Server is available ?

Web Space Server is localized out-of-box in 22 languages , out of which Sun provides localization support for Japanese (ja) and Simplified Chinese (zh_CN). Remaining languages are community driven

FAQ 4.0 : Can I add new Language ?

Yes ,Web Space Server is Internationalized. Allow you to add new languages which is not shipped out of box.

Refer Localization section of Admin Guide for exact steps of how to do the same.

FAQ 5.0 : Where I can get more information about Localization ?

Refer Localization section of Admin Guide

FAQ 6.0 :  If you have Ask Me :-) ...

Beginning ... Focus ... Success ... Beginning  ............ (Life goes on )

Monday Dec 22, 2008

How to configure WebSynergy/Liferay on MySQL for UTF-8

Recently I was using WebSynergy with default database (HSQL in memory) and all my localized data were just doing fine. Happily making trip to UI to Database and vice versa. Then when I switch my database to MySQL , everything went haywire , Data turned in to ??? (okie let me be clear , when Data turns to ??? its mostly case of wrong encoding).

It was small challenge for me to get it right on MySQL. Challenge is Challenge. 

I have explored on MySQL side and found that , it very easy to create database which can handle UTF-8 character (by default it comes in ASCII). so create database to handle WebSynergy data with UTF-8 encoding.


 :-) .. am I done .. I did a check but situation refuse to change .. there was something else also needs to be done. To call it done.

Database is in UTF-8 but communication between Portal and Database was not in UTF-8.  How to enable that?

I have found a simple straight way.

Add following two properties to "LiferayPool" and "JIRAPool".


.. are we done .. Yes , we are done. Enjoy the advantages of MySQL with WebSynergy in language you want to communicate.

"No Problem is small problem until you know the solution" 

Wednesday Aug 13, 2008

One resource bundle per One Application - I18n and L10n will be easy

<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-2367267-3"); pageTracker._trackPageview(); </script>

First what is with this some what mystry title.

In simple words , I would like to highlight advantage of keeping only one resource bundle( aka. one property file which contains all the localizable messages) per One Application.

Source of insipiration was Liferay.

Let me give you more idea of how it will look like.

1) Make sure all your translatable strings are put on one property file  ex.

This will help to your customer who might want to add new langauge or want to add new strings to existing language or change strings to existing langauge. Easy to find where to do localization.

2) Organized it well . Define a rule to write key name.

ex. first_name=First Name

     account_number=Account Number

This will help to easily find of what this key represents in localized bundle.

3) Keep it in Alphabetical order

This will ensure that duplicate properties does not exists in your bundle.

4) Now you can keep common utility class which will load the bundle based on Locale user wanted

This will help all your other class as they do not need to bother about loading bundle. They can focus on solving business logic (that's where money comes from)

Last but not the least ... Innovation is mother of all invension ... so innovate whether it is necessasity or not :-) ...

Thursday Aug 07, 2008

Hibernate - POJO and HBM file creation best practice

Recently I was working on Hibernate and created a number of POJO and their corresponding hbm file. I am  using Netbeans (who has support for Hibernate plugin , real helpful , )

Certain best practice I would like to make work more interesting.

  • Keep table name and POJO name same.

ex. Create new Java Class  i.e Person , Use hibernate plugin to create .hbm file , Give same name as Class file , Select Person as class name on next screen.

  This will create .hbm file with name as Person , no need to provide table attribute. Hibernate will create table with same name.

This aovides unnecessary complexities in distinguice table name and class name

  • Keep POJO variable name same as Field name

      Do no mention Column attribute while declaring <Property> in .hbm file. Hibernate will create column with same name.

  • Try to keep ID as primaray key for all the Tables where possible. Less to remember and more time to figure out solution to problem on hand. 
  • How can I forgot my Dear I18n. There is nothing much as long as you make sure that created Database has UTF-8 encoding.
  • One more point , Certain tables are used to keep default list. If the list compoment is localizable make sure you take care of fetching localized values from proper resource bundle before publishing to User Interface.

Resources :

More will follow as I learn more ... enjoy your life ... n keep doing innovation ... only way to survive ...

Tuesday Jun 10, 2008

I18n of Junit Testcases

I always believe that Maximum I18n testing should be done before build release to QA. To do that I keep finding out various way to do more and more i18n testing during development.

In that I stuck with this idea of creating Junit testcase for I18n testing. Then I relize it would be good to make Junit testcase itself  I18n. So that input to Junit testcase can be non-english data. It will check the flow of non-english data in application. I have done that for one of module for my product. i.e Portal Server.


I18n'ed JUnit test case input which will help in doing I18n testing in JUnit.

How to do it?

I18n input of Junit Test case

  • What I mean here by I18n'ed test case is to remove hard coded input(which are localizable) from Testcase and load them using ResourceBundle. So to test those testcases with non english value would be easy (creating a new resource bundle with non-english values).
  • so from developer point of view , instead of hard coding input to test case in Java program they have to read from resource bundle. Then g11n(or developer) team can create resource bundle for other language and integrate in same framework. It will then run the same testcases with non English values. this way we can reuse junit testcases to perform i18n unit testing.


ex. Let me give you example of one of CMS junit testcase
Testcase to create category.
source :
Before :


String categoryName="TestCategoryCreation";

...(code to test creation) ...


In this testcase category name "TestCategory" is hardcoded in java program. I have removed this hardcoding and load this value from Resource Bundle.

Now :

One new class variable needs to be added.

ResourceBundle rb;

Two new function will be added:

Locale selectLocale(){
return new Locale("en");
void loadResourceBundle(){
rb = ResourceBundle.getBundle("CustomResource",selectLocale()) ;
String categoryName=rb.getString("TestCategoryCreation");
...(code to test creation)
... }

As shown above, resource bundle will be load once for Test program and it will be used by all the testcases within it. so now when developer run this testcases in english environment and it will work as it was previously.

Now How to leverage this testcase for I18n testing.
Create one interface: I18nTestFramework - which will have one method
Locale selectLocale();

Base Testcase Program has to implement this Interface.

i.e public CategoryTest extends TestCase implements I18nTestFramework

How to provide Localized value for Testcase

Then we need to create New Test program for language in which you want to do I18n testing which will have only one method selectLocale(). ex. "ja".

CategoryJaTest extends CategoryTest {
Locale selectLocale(){
return new Locale("ja");

Now on whenever Junit framework will be executed. It will execute this test program also and since locale set to "ja" . Resource bundle for japanese will be loaded. which will be used to test all the tests of CategoryTest since it is extended by CategoryI18nTest.

You can create Category<locale>Test java program , ResourceBundle(properties) file for all the language in which I18n testing needs to be done.

(phir milenge ... (cu later)) 

Monday Jun 09, 2008

I18n Best practices for web application- Part 1

I have created clear and concise best practices list for making your application I18n'ed.


  • No hardcoded strings
  • Data format I18n
  • Number format I18n
  • Usage of  Apostrophe in Message Format class. 
  • Currency I18n
  • Sort I18n
  • Calendar I18n
  • Read/write file in UTF-8
    • Use methods like :public OutputStreamWriter(OutputStream out, String charsetName); public InputStreamReader(InputStream in, String charsetName)
  • Locale lookup should be correct - Find out what lookup mechanism needs to be used.
  • Send/Receive Locale when communicating with other compoments
  • If any property in property file does not need to be locaized put a comment on top property file.
  • Make sure property file does not have duplicate properties
  • When you use Message format to parse string make sure "'"(aphostrophy) in string is escaped.
  • File system name should be allowed to i18n

JSP Prgoram

  • Encoding of file should be "UTF-8"
    • <%@ page contentType="mimeType ;charset=characterSet ?" | "text/html; charset=UTF-8" %>
  • Use JSTL taglib to include the messages in the JSP file.
  • Request and Response should be in "UTF-8"

Resource Bundle

  • Should not use duplicate key properties file
  • Try to create less number of Property files
  • Try to use same message which already found in other components or even products if it make sense.
  • Do not change layout of message once translated
  • Property file for UI message and Log message should be SEPARATE
  • Message should not be slang or culturally sensitive
  • Always create file along with base property file


  • Each button/textfield should have enough space to accommodate localized sentences
  • Layout and Text rendering
  • Input validation should consider multibyte data


  • If you are writing a WEB UI, the UI should appear in the client locale, not the server locale. Logging should be done in the server locale to avoid log messages with mixed data from different locales. Use UTF-8 as encoding for the web UI, because UTF-8 supports all languages.


  • Reading and writing data to/from database should be in UTF-8

JUnit Testcase

  • Make sure all your Junit Testcase is I18n'ed. This will help in great way to integrate i18n testing in Unit testing.


Refer AJAX I18n


Wednesday Jan 30, 2008

I18n 360' testing approach at Step-IN 2008 Conference

Recently I had been to one of the most beautiful hotel aka. palace in Bangalore.  No marks for guessing its Leela Palace.
I had been there before but this time reason was not for pubbing (athena)  as it used to be.I was there to give talk at Step-in 2008 Conference (ASIA's biggest testing conference - as organizers claims).

My talk was on Internationalization(I18n) 360' testing approach , the concept which close to my heart and job. Its fresh , unique and quick at results. Implemented in Portal Server 7.2 aka.OpenPortal development.

My topic was selected for Pre-conference tutorial , A long 210 minutes( 3 hours and 30 minutes). It was indeed long time to stand , deliver and interact but my passion toward the subject was a big help. Curiosity of delegates in terms of their questions regarding I18n , their day to day use cases , their business case has never made me felt that it was long. In fact I had to rush a bit in last stage of Presentation.


Let move to what I shared there.

It was started with Introduction of I18n world (I18n , L10n , G11n) which also covered all the basic terminologies like Character , Charset , Unicode , UTF-x , Glyph , Font , Locale. My audience was enjoying every bit of information as most of them were aware about I18n but this details made them realize what the hack it is. This session was resulted in lots of questions and interesting discussion. They allowed to move ahead with the promise that I will spend quality time after talk  to share more of my understanding about I18n world.

Next session was regarding I18n 360' testing approach , which in simple teams means involving I18n in every stage of product development , starting as early as product planning. How I18n play role in Requirement phase , Design phase , Implementation phase and most importantly QA phase. Even in documentation also I18n has role to play. Usage of real time example and case study has made this session most entertain one. If it got you curious enough here is the Presentation for you

After that I had shown them live demo of how to do i18n testing in stand alone application and web application. This followed by demo of  I18n testing automation using Open Source automation tool Canoo. At last as a common practice Question and Answers.

 It was a wonderful and memorable experience for me. It was first time I had been to such reputed conference to represent Sun. I had been to Universities for talk earlier but this was unique and challenging as audience was mix of managers , consultants  and testing engineers.

Mahipalsinh Rana


« February 2017