Struts Internationalization

Internationalization means preparing your application to support for different language.

For implementing different language we need to do the following:

1) Create a Resource bundle for messages.

2) Manage Locale using Http Header.

3) Retrive bundle messages using UI tags.

Bundle can be created global to application or specific to package or action etc.

For setting global resouce file we need to make an entry in file:


and we will be having resource file with name for english.

And in this property file we will be having enrty like:

username=Enter User Name

Other than this global resource file we can create action or package specific resource file with name as:,, etc.

Various ways we with which we can access message properties:


<s:property value="getText('username')" />

<s:text name="username" />

<s:textfield key="username" name="data"/>

Using i18n tag:

<s:i18n name="some.package.bundle">
     <s:text name="username" />

For changing the language we need to change the request locale of Http Request and then application will automatically pick the corresponding language resource bundle file.