ADD A NEW LANGUAGE TO LIFERAY (Detailed Step by Step)

In reference to the blog.

One among the large set of features that Liferay provides is its ability to support multiple languages. And we all know Liferay is the most flexible portal for customization out there. Liferay currently supports about 40 languages out of the box.  The full list of translated languages may be seen here: http://translate.liferay.com/pootle/.

Consider you encounter a situation where you have to add a new language support to Liferay that is not one of the ones supported? In other words, in this blog we will see how to add a new language to Liferay portal and how to define portlet keys for your custom portlet.

"Thai" language is considered as an example for this blog.

Following is the summary of steps that we will need to carry out. Later section tells you about the details of each step.

1.     Each language that Liferay supports, has its own servlet-mapping and url-pattern defined for the same in "web.xml" (which is inside LIFERAY_HOME\tomcat-<version>\webapps\ROOT\WEB-INF), so we will have to make this arrangement for "Thai" language. This first step will activate "Thai" language in Liferay.

2.     In order to make "Thai" language visible in control panel and in Language portlet, we need to define the new locale in "portal-ext.properties".

3.     Finally you need a hook to add a new "language_<th>.properties" file with all the keys and their respective translations you want for "Thai" language.

Yes it is as simple as it seems, 3 steps is what it takes.

Step1: Open Liferay "web.xml" (which is inside LIFERAY_HOME\tomcat-<version>\webapps\ROOT\WEB-INF). To add a new language (in this case "Thai"), add the following code of servlet-mapping inside "web.xml":

<!-- Newly added language THAI -->

            <servlet-mapping>

                        <servlet-name>I18n Servlet</servlet-name>

                        <url-pattern>/th/*</url-pattern>

            </servlet-mapping>

 

 

Then find the url-patterns within opening and closing tags of  web-resource-collection of <security-constraint> in your "web.xml" and add the following entries:

<url-pattern>/th/c/portal/protected</url-pattern>

Save "web.xml" file.

Step2:  In order to make "Thai" language visible in control panel and Language portlet, we need to define the new locale in "portal-ext.properties":

Open "portal-ext.properties" and add the following:    

            locales=th,ar_SA,eu_ES,bg_BG,ca_AD,ca_ES,zh_CN,en,en_US

Save the "portal-ext.properties" file.   

By doing so, user will only see 7 languages in control panel including "Thai" language. You would like to have full set of languages,  in that case you need to copy the full locales from Liferay "language.properties" file.

Now create an image with name "th.png" and put it into the folder: "Liferay-Home\tomcat-<version>\webapps\ROOT\html\themes\classic\images\language".

Restart your Server and go to Control Panel -> Portal Settings ->

Display Settings. You see the following screen.

Move “Thai” from "Available" to "Current" language.

 Click on Save button.

Add Language portlet to one of the pages in the site.

You must be wondering where did i get that flag from , 

Quick fix to get the flag is to add it to webapps/ROOT/html/themes/classic/images/language

This step (Adding flag) is not mandatory, if you dont add the flag, you will still see thai language icon as text. 

Boom , Goal is achieved. We can now see a new language in Language portlet.

Click on new language and see the changes, Wait, There are no changes, because we have not translated all keys of Liferay in "Thai" language. To do so you will need to write a hook as follows.

Step3: Finally you will need a hook to push your own "language_<langCode>.properties" file into Liferay. In this case it is "language_th.properties".

Follow the steps given below.

          1. Create a new plugin project with name "Thai-Language-hook". Select hook as Plugin type. Click Finish.

          2. Create a new hook configuration in the project. For this you have to right click on the "Thai-Language-hook" project, select New and then select Liferay Hook Configuration. Now select Language properties option under Select hook type(s) to create. Click on Next button.

1.     Click on Add button to specify language property file. Specify  "language_th.properties" as follows:

Click Ok. Click Finish.

1.     Open "language_th.properties" file which is inside content folder of ".....docroot/WEB-INF/src" folder of project. Now add all the keys you want to translate from Liferay "language.properties" file.

Save the file.

1.     Deploy the hook and see the changes. I have taken different keys so that you understand that you can modify all keys of Liferay.

1.     Test it properly with different keys.

                 References:

https://www.xtivia.com
http://www.liferay.com/community/wiki/-/wiki/Main/Translating+Liferay+to+a+New+Language
http://www.liferay.com/community/wiki/-/wiki/Main/Languagedisplay+customization

Blogs
Step 4: Contribute your translation by getting in contact with the translation team at https://www.liferay.com/community/forums/-/message_boards/category/1925364 (it doesn't need to be finished for this)
hi , please i need a help i need to add new language like thailand language in liferay 7 . in liferay 6.2 it is very simple but in liferay 7 i don't find any solution
I finally got it to work for a new language. Here is the link to the answer to your question on Stackoverflow: https://stackoverflow.com/questions/39394800/how-can-i-add-a-new-language-in-liferay-7

Here are the steps:

1. Create a new theme, or modify existing theme to :
add your flag file in SVG format as images\lexicon\flags-xx-YY.svg (where xx-YY is your locale, case-sensitive)

2. Open the file icons.svg in the same folder and add your flag SVG elements as a symbol among the other symbol elements:
</symbol><symbol id="xx-yy" viewBox="0 0 512 512">
<rect y="64" fill="#B0BEC9" width="512" height="384"/>
<rect x="16" y="80" width="480" height="352" fill="#fff"/>
<rect ..... />
<circle .... />
</symbol><symbol id="zh-cn" viewBox="0 0 512 512">

3. Deploy, or re-deploy, the theme and choose it as the active theme for the pages you want.

4. Clear the browser cache if needed.
Hello,
I would like adding a new language in Liferay DXP, someone finds any solution?.

Hello

i need help i am able to add language it works properly but i won't be able to add icon of that language please provide some information about how to add language icon in detail.

 

Thanks

This article is from 2015 and written for a previous version of Liferay. I'd recommend to come to the forums and ask your question there. Don't forget to add a lot more information, e.g.: Which version are you on, what did you try already?

I was able to add language icons in Liferay 7.x using new SVG mapping as described above.

I am trying to add gujarati language icon for that i am creating custom-theme. theme build and deployed successfully but now i am confused in which folder i have to add .png and .svg file i have to create folder or i have to just copy it in existing folder please give me detailed path in which i have to copy .png and .svg file

Hi Aneri

 

In custom theme there is a folder /image/language, add your png file there with your language name like ta_IN.png in case of tamil language.

 

Add svg file in your custom theme at /images/lexicon location.

 

<a href="https://indonesianlanguagetranslator.com/translation-tips-on-selecting-the-best-translator/"> Tips on Selecting the Best Document Translation and Legal Translation </a> can make it easier for you to learn: D

Hi everyone, thanks for sharing this with the community, is very usefull. I´m trying to add valenciano to my portal, which works with liferay GA 7.1. Liferay doesn´t reccognice valenciano as an idiom so it doens´t appear in the portal. I´m following this guide so I´ve added ca_AD as a new idiom in the portal and I´m editing language propeties file. Then, I put this file on the server and the portal doesn´t add all the translations that I´ve inserted in the file, why this is happening?? 

The second problem is when I enter in the portal selecting valenciano. The url show "ca_AD". How can I change the url? I want that the url contains the prefix "va" instead "ca_AD". Thanks