Wiki

Main | Proposals

Translating Liferay Portal

(Redirected from Translating Liferay to a New Language)
Documentation: Languages

This page is about translating the Liferay application. For adding translations of wiki articles, see Translations.

Liferay Portal is an application that can be localized to multiple languages, that even allows each user to choose a different languages of the ones supported by the platform. By default Liferay provides translations to a large number of languages. Some of those translations are reviewed carefully by native speakers although others are automatically translated (you can help if this is the case for you language!).

This article explains how to translate Liferay to a new language or how to improve an existing translation.

Step 1) Find out if the translation to the language already exists #

Liferay maintains the sentences used throughout the portal in a set of files of the form Language_(Language code).properties where (Language code) identifies the language as defined by the Java Internationalization specs.

These files are stored within a directory named 'content' which is deployed to the classpath. The exact location of this directory varies depending if you are looking at the sources or a deployed installation. Here are the most common cases:

  • Liferay sources: portal-impl/src/content/Language_(Language code).properties
  • Extension Environment: the files are inside modules/portal-impl.jar in the path content/Language_(Language code).properties
    • The extension environment allows making changes to these files without actually modifying them by using the equivalent files of the form ext-impl/classes/content/Language-ext_(Language code).properties
  • Liferay deployment: within $LIFERAY_WAR/WEB-INF/lib/portal-impl.jar find content/Language_(Language code).properties
    • In the Tomcat Bundle: within $TOMCAT/webapps/ROOT/WEB-INF/lib/portal-impl.jar find content/Language_(Language code).properties

Step 2) Editing the file #

The Language_(Language code).properties files are regular text files that can be edited with a simple text editor. Java properties editors available in the most modern IDEs can also be used.

To create the translation for a new language make a copy of the file for an existing language and change the (Language code) to the one associated to the new language. The language code has the following syntax (brackets denote optional portion)

<language code>_<[country code>_<variant code>]

Note that you may have to modify more than one language.properties files. In this page you will find the Location of language.properties

For more information check Internationalization: Understanding Locale in the Java Platform

Dealing with non-ASCII characters (Only for versions previous to 6) #

When writing a translation to a language that uses non-ASCII characters some problems may arise. This section explains why this may happen and how to solve it.

When using a non-ASCII character in a Language*.properties file the text editor will use a different encoding system to be able to represent those files. If the encoding does not match the one used by the portal the non-ASCII characters will not be shown correctly to the user.

While this can be solved by making sure the file is saved with the same encoding, a better way to solve the problem is to encode the file with a Java specific format that is independent of the encoding used. This ensures that even if the encoding used by the portal is used the non-ASCII characters will still be read correctly.

Java provides a command line tool called native2ascii that allows converting from any encoding (specified as a parameter) to Java's format. Liferay uses this tool for all languages that need it (actually, all but English). It stores the files with the original encoding with the extension .native and the does a conversion:

Language_(Language code).properties.native ==> Language_(Language code).properties

As a conclusion, if you are using liferay 6 or newer you don't have the native files and you don't have to worry about the non-ASCII characters at all. Otherwise:

  1. When editing Language files within Liferay's sources or in the No InterWiki reference defined in properties for Wiki called ""! never edit the Language_(Language code).properties files directly. Instead edit Language_(Language code).properties.native.
  2. When editing them in your own environment we recommend using a similar pattern, modifying the .native files (or whatever extension you like) and using native2ascii' to generate the actual Language file
  3. You only need to deploy the files of the form Language_(Language code).properties (without the .native extension)

Step 3) Installing the new or modified translation #

Once you have a new or improved translation file they should be placed along with the other Language files in the locations listed in step 1.

If it is a new translation it will also be necessary to register it within Liferay. To do that you'll have to edit the files portal.properties or portal-ext.properties and add the new language to the property locales. For example to add

 locales=ar_SA,ca_AD,ca_ES,...tr_TR,vi_VN,**ro**

Step 4) Contributing the translation to Liferay (Optional) #

If you want to contribute the new translation so that it's included in the next version of Liferay, follow these steps:

  1. Update the translation to the latest version
    1. Obtain the latest version from our Subversion Repository: svn://svn.liferay.com/repos/public/portal/trunk/portal-impl/src/content/
    2. Compare with your translation (if you already have one) paying special attention to new or removed language keys
  2. Create a JIRA issue with the title Improved translation to LANGUAGE or Added translation to LANGUAGE
    1. You may want to create the JIRA issue before you start doing the translation or changes to coordinate with other people that maybe working on the same task
  3. Attach a patch that contains only the changes that you've made to the properties file. Be sure that the patch uses UTF-8 encoding.
    1. To create the patch use the svn diff command or an SVN IDE such as SmartSVN or TortoiseSVN.
  4. Assign the issue to an official contributor. The official contributors so far are listed in the page for the Liferay Translation Team. If there isn't any official contributor for your language, leave it assigned to SE Support and write a post in the Liferay Translation Forums announcing the contribution.

Other optional steps #

16694 Views , 0 Attachments 0 Attachments

Average (0 Votes)
Comments Flat View

How are managed the resource bundles keys between old and newer Liferay releases?
Do you only add new keys (to guarantee backward compatibility)?

Thanks,
Denis.

Posted on 1/13/10 8:32 AM.

Top Top