Sun GlassFish Web Space Server 10.0 Administration Guide

Localization Support

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

The following sections describe how to perform localization:

Setting the User-Preferred Language in Web Space Server

Users can use Web Space Server in any of the supported languages.

ProcedureTo Set a User-Preferred Language

  1. Log in to Web Space Server.

  2. Choose My Account from the Welcome menu.

    The Control Panel is displayed.

  3. Choose Display Settings under Miscellaneous in the menu on the right.

  4. Select a language from the Language drop-down list.

  5. Click Save.

    The user interface changes to the language selected.


    Note –

    You can use the same page to change the time zone and the greeting message.


Adding a New Language Support

You can add localization support for a language that is not supported by Web Space Server by default. This section describes how you can add localization support for a new language.

ProcedureTo Add New Language Support

This task describes how to create a portal-ext.properties file, and make changes to it to support localization.

  1. Create a temporary folder. In this example, name the folder as test.

    mkdir /tmp/test

  2. Copy portal-impl.jar to the tmp folder.

    The portal-impl.jar file contains resource bundles for Web Space Server. This JAR file is located in the GlassFish install-dir/domains/domain1/application/j2ee-modules/webspace/WEB-INF/lib/ directory.

    cd GlassFish-install-dir/domains/domain1/application/j2ee-modules

    cp webspace/WEB-INF/lib/portal-impl.jar /tmp/test

  3. Change to the tmp directory.

    cd /tmp/test

  4. Extract the portal-impl.jar file.

    jar -xvf portal-impl.jar

    The portal.properties file will be placed in the current directory.

  5. Open portal.properties and copy the locales property from the Languages and Time Zones section.

  6. If a portal-ext.properties file does not already exist, create a text file with that name.

    The default location of portal-ext.properties is GlassFish home/applications/j2ee-modules/webspace/WEB-INF/classes/portal-ext.properties.

  7. Paste the locales property into the portal-ext.properties file.

  8. Add the new locale at the end of the locales property in the format LanguageCode_CountryCode.

    See the following links to find language and country codes:

    For example, if you are adding support for Hindi, you need to add hi_IN at the end of locales property as follows:

    locales=ar_SA,ca_AD,ca_ES,zh_CN,zh_TW,cs_CZ,nl_NL,en_US,fi_FI,fr_FR,de_DE,el_GR,hu_HU,
    it_IT,ja_JP,ko_KR,nb_NO,fa_IR,pt_BR,ru_RU,es_ES,sv_SE,tr_TR,vi_VN,hi_IN
  9. Save the portal-ext.properties file.

  10. Navigate to the content folder and open the Language.properties file.


    Note –

    A folder named content was created when you extracted the portal-impl.jar file.


  11. Translate all the strings you want to localize from temp/test/content/Language.properties to the new language.

  12. Rename the translated Language.properties file to Language-ext_LanguageCode.properties.native.

  13. Run the following command on the directories that contains the Language-ext_LanguageCode.properties.native file:

    native2ascii -encoding UTF-8 Language-ext_LanguageCode.properties.native Language-ext_LanguageCode.properties

  14. Create a directory structure webspace/WEB-INF/classes/ under ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace/customs, and copy portal-ext.properties file to it.

  15. Create a directory structure webspace/WEB-INF/classes/content under ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace/customs, and copy Language-ext_LanguageCode.properties.native file to it.

  16. Change to the ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace directory.

    cd ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace

  17. Run ant -f synchronize.xml.

  18. Restart theGlassFish server.

ProcedureTo Verify the Localization of the Interface

  1. Log in to Web Space Server as the admin user.

  2. Choose My Account from the Welcome menu.

    The Control Panel is displayed.

  3. Choose Display Settings under Miscellaneous.

    The new language setting is reflected in the Language drop-down menu.

  4. Select the language for the user and click Save.

    The user interface is changed to the new language.

Removing Localization Support for Unwanted Languages

Generally, users don't require localization support for all languages that are supported by Web Space Server. This section describes how you can remove localization support for the languages that are not required.

ProcedureTo Remove Localization Support for Unwanted Languages

  1. Create a temporary folder. In this example, name the folder as test.

    mkdir /tmp/test

  2. Copy portal-impl.jar to the tmp folder.

    portal-impl.jar contains language resource bundles for Web Space Server. This JAR file is located in the GlassFish install-dir/domains/domain1/application/j2ee-modules/webspace/WEB-INF/lib/ directory.

    cd GlassFish-install-dir/domains/domain1/application/j2ee-modules

    cp webspace/WEB-INF/lib/portal-impl.jar /tmp/test

  3. Change to the tmp directory.

    cd /tmp/test

  4. Extract the portal-impl.jar file.

    jar -xvf portal-impl.jar

  5. Open portal.properties and copy the locales property from the Languages and Time Zones section.

  6. If portal-ext.properties does exist in Web Space Server then paste the locales property into it. Otherwise, create a text file (using any text editor) and name it as portal-ext.properties, and paste the locales property into it.

    Default location of portal-ext.properties is GlassFish home/applications/j2ee-modules/webspace/WEB-INF/classes/portal-ext.properties.

  7. Edit the locales property to include only the languages that are needed.

    For example, if you want to support only English, German and Spanish, remove all the unwanted locales so that the locales value looks as follows:

    locales=en_US,de_DE,es_ES
  8. Save the portal-ext.properties file.

  9. Create a directory structure webspace/WEB-INF/classes/ under ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace/customs, and copy the portal-ext.properties file to it.

  10. Change to the ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace directory.

    cd ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace

  11. Run ant -f synchronize.xml.

  12. Restart the GlassFish server.

    The server will redeploy websynergy.war and update portal-ext.properties under applications/j2ee-modules/webspace/WEB-INF/classes.

Enabling the Guest Users to Select a Browser Language

Guest users can select their preferred browser language.

ProcedureTo Enable Guest Users to Select a Browser Language

  1. Create a temporary folder, named test.

    mkdir /tmp/test

  2. Copy portal-impl.jar to the tmp folder.

    portal-impl.jar contains language resource bundles for Web Space Server. This JAR file is located in the GlassFish install-dir/domains/domain1/application/j2ee-modules/webspace/WEB-INF/lib/ directory.

    cd GlassFish-install-dir/domains/domain1/application/j2ee-modules

    cp webspace/WEB-INF/lib/portal-impl.jar /tmp/test

  3. Change to the tmpdirectory.

    cd /tmp/test

  4. Extract the portal-impl.jar file.

    jar -xvf portal-impl.jar

    The portal.properties file will be placed in the current directory.

  5. Open portal.properties and copy the locale.default.request property from the Languages and Time Zones section.

  6. If portal-ext.properties does exist in Web Space Server then paste the locale.default.request property into it. Otherwise, create a text file (using any text editor) and name it as portal-ext.properties, and paste the locale.default.request property into it.

    Default location of portal-ext.properties is GlassFish home/applications/j2ee-modules/webspace/WEB-INF/classes/portal-ext.properties.

  7. Set the property to locale.default.request=true.

  8. Save the portal-ext.properties file.

  9. Create a directory structure webspace/WEB-INF/classes/ under ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace/customs, and copy the portal-ext.properties file to it.

  10. Change to the ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspacedirectory.

    cd ZIP_ROOT/webspace-for-gfv2/var/webspace/war-workspace

  11. Run ant -f synchronize.xml.

  12. Restart the GlassFish server.

    It will redeploy websynergy.war and update portal-ext.properties under applications/j2ee-modules/webspace/WEB-INF/classes. Clear browser cookies before accessing Web Space Server interface to allow the changes to take effect.

Precedence Hierarchy for Language.properties Files

Language and display information is defined in the Language.properties, as well as various other Language_LanguageCode.properties files for foreign languages. When you extract the portal-impl.jar file, these files are placed in the content folder. Language.properties is the primary and default language definition file, but definitions in that file may be overridden by language-specific definitions. For example, the file Language_en.properties contains the English versions of most of the definitions, the file Language_fr.properties contains the French version, and so on.

Language files can further have locale-specific definitions. The Language_en_US.properties file contains English phrase variations further defined for the United States. Other languages can also have locale-specific definitions.

Rules of Precedence

    The hierarchy of precedence for different Language.properties files is:

  1. Language-ext.properties takes precedence over Language.properties.

  2. Language-specific versions take precedence over the non language-specific versions. For example, Language_en.properties takes precedence over Language.properties.

  3. Location-specific versions take precedence over the non location-specific versions. For example, Language_en_US.properties takes precedence over Language_en.properties.

    For the Language.properties file for English, Language-ext_en_US.properties has the highest precedence and the Language.properties file has the least precedence. The hierarchy is:

  1. Language-ext_en_US.properties

  2. Language_en_US.properties

  3. Language-ext_en.properties

  4. Language_en.properties

  5. Language-ext.properties

  6. Language.properties

Changing the Existing Language Entries

You can easily change existing English and foreign languages entries in Web Space Server. Consider the example of changing the name of a portlet from Message Boards to Forums. To do this when English is the default language, you would create the Language-ext_en.properties to override the Language_en.properties file. In Language-ext_en.properties, duplicate the content in the Language_en.properties file, and replace the entry javax.portlet.title.19=Message Boards with javax.portlet.title.19=Forums. The portlet Message Boards is renamed to Forums.

You can also add new language entries for customization or for new portlets. For example, you can create an entry similar to javax.portlet.title.EXT_1=Reports to add the name of a new portlet named Reports.

Customizing Portlet Names While Localizing

You can customize the name of a ported for any language by using the Look and Feel button on the portlet. Consider the example of localizing Web Space Server to French. In this case, the name of the Admin portlet translates as Administration du portail. You might prefer to have a customized name for the Admin portlet when Web Space Server is localized to French.

ProcedureTo Customize the Name of a Portlet While Localizing the User Interface

  1. Log in to the Web Space Server as the admin user.

  2. Click the Look and Feel button on a portlet.

    In this example, click the Look and Feel button on the Admin portlet.

  3. Select the Use Custom Title option.

  4. Select a language from the language list.

    In this example, select French.

  5. Type a title for the portlet in the selected language in the Portlet Title box.

    In this example, type the name Administration.

  6. Click Save.


    Note –

    For the changes to take effect, you may have to save twice: once with the Use Custom Title option deselected and again with selected. Some times the portlet name in the default language too may have changed. You need to verify this.


  7. Choose My Account from the Welcome menu.

  8. Choose Display Settings under Miscellaneous.

  9. Select a language from the Language list that is the same as the language selected previously.

    For example, select French.

  10. Click Save and navigate back to the community page.

    You can see the changed name of the portlet in the localized version. In this example, the name of the Admin portlet localized to French is changed from Administration du portail to Administration.