Friday, October 4, 2013

Localizing WSO2 Carbon Products - Part 1

Introduction to Localization of Carbon products 

WSO2 products are used all over the world and it's users may need to translate a product into different languages when adapting that particular product into their country or region. This process of translating the product into different languages is known as Localization.

If you open up any WSO2 product and go inside CARBON_HOME/repository/components/plugins, you will see number of jar files. Among those jars the ones that have their names end with ui_<version>.jar are usually the bundles that contains the resources files that needs to localization.

For an example, let's take WSO2 Identity Server 4.5.0 and go to repository/components/plugins. From that let's select org.wso2.carbon.claim.mgt.ui_4.2.0.jar. Open up the jar using an archive manager or in any preferred way. You may observe folder structure similar to this.

The file you see at the very end; file is the one which the page in the UI used to read string values from. If you open the file you'll observe that it contains some name value pairs as below.

claim.mgt=Claim Management



cancel=Cancel Management

new.claim.details=New Claim Details
First make a copy of this file and name it with the code of the locale of your preferred language. For an example if you want to localize to French, name of your file should look like And then you need to change the value of the name value pairs to go with your language. For an example you might change the first pair as follows.

claim.mgt=Gestion des r├ęclamations
In order to localize the whole product, you need to add a resource file for each ui bundle with your desired language.

You can have any number of resource files inside one jar as follows. ( So that you can switch between different languages very easily.)

After that go ahead and change the locale either through browser settings or passing the locale through a url parameter ( as locale=fr ). Now if you refresh the page you will see the page being localized in your preferred language.

But the problem with this approach is that if you happen to patch any of these jars, you will have to update the file of your preferred language every time that you do so.

So the recommended approach is to localize through fragment bundles which gets attached to the specified host. In my next post I will be explaining how to generate the fragment bundles to localize WSO2 carbon products.

No comments:

Post a Comment