Adding A Language
Liferay currently supports about 50 languages out-of-the-box. Translation is complete for many of these languages and some are still in the translation process. Each language has its own language properties file containing keys for its language. But there are more than 6000 languages in the world. If you must add an additional language, here’s how.
Adding A New Language
By default, the portal.properties
file specifies all languages available in Liferay. To add a new language that is not specified,
Take note of the ISO 639-1 standard code for your language (e.g. the ISO code for Amharic would be
am
).Take note of the ISO 3166-1 alpha-2 two-letter country code for your language. (e.g. the ISO code for Ethiopia would be
ET
).Modify and replace the
web.xml
file found in your Liferay installation:[LIFERAY_HOME]/tomcat<version>/webapps/ROOT/WEB-INF/
. Add your new language under the<web-resource-name
> section. For example,<url-pattern>/am/c/portal/protected</url-pattern> <url-pattern>/am-ET/c/portal/protected</url-pattern> <url-pattern>/am_ET/c/portal/protected</url-pattern>
Modify and replace the
shielded-container-web.xml
file found in your Liferay installation:[LIFERAY_HOME]/tomcat<version>/webapps/ROOT/WEB-INF/
. Add your new language under the<servlet-mapping
> section. For example,<servlet-mapping> <servlet-name>I18n Servlet</servlet-name> <url-pattern>/am/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>I18n Servlet</servlet-name> <url-pattern>/am-ET/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>I18n Servlet</servlet-name> <url-pattern>/am_ET/*</url-pattern> </servlet-mapping>
Create your
language.properties
file for your language and use the ISO code in your file name. For exampleLanguage_am.properties
for Amharic:create-account=መለያ መፍጠር email-address=የ ኢሜል አድራሻ forgot-password=መክፈቻ ቁልፉን ረሳኽው home=መነሻ ገጽ password=ፕስወርድ powered-by-x=በ {0} የተጎላበተ remember-me=አስታወስከኝ search=የፍለጋ አሞሌ sign-in=ስግን እን
Create a language module with the
language.properties
file you created and deploy the module to your Liferay installation. See Overriding Global Language Translations to see a sample project and specific instructions on creating this module.Create or modify your
portal-ext.properties
file in your installation’s Liferay Home folder. Note, this file overrides the enabled default locales defined in theportal.properties
file. Therefore list all the languages you plan to use in theportal-ext.properties
file. Define bothlocales
andlocales.enabled
. For example:locales=am_ET,ar_SA,fa_IR,en_US,zh_CN,ja_JP locales.enabled=am_ET,ar_SA,fa_IR,en_US,zh_CN,ja_JP
Once the module is deployed, navigate to Control Panel → Instance Settings → Localization. Verify and move the new language to the current languages. Click Save.
Change your default language to the new language and click Save. The new language is now used by the Liferay instance.