Saturday, September 17, 2016

Localization (l10n) in Liferay

In the previous tutorial about Internationalization (i18n) in liferay we use Language portlet to change the language .But what if we don't want to use language portlet.Today we create portlet that change language by using Locale means if our website open in France that all website change to french and if our website open in U.S.A than all content change to English. So lets start this Step by Step:-

Step 1:-Create portlet with properties file
Just create a same portlet as discuss in  Internationalization (i18n) in liferay and create a file for french  and file for English in content folder.And paste this Content:-
welcome_message =Welcome to Liferay is Easy
welcome_message =Welcome to Liferay is Easy in French

Note:- I don't know how to write this in french so i just change the message.

Step 2:-Change the controller
Inside open your controller and paste this:-

Here we get the default locale of the machine which we set when we install our Operating System and than get the message from properties file using this default locale. And Finally set this to request so that we can use this on jsp.

Step 3:-Change the view
open view.jsp and paste this:-


That's it you can deploy and check the output.You can check out video tutorial for the same.

Hope this will Help....

You can Download Source code from  Localization in Liferay.

Related Post:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!