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 Language_fr.properties file for french and Language.properties file for English in content folder.And paste this Content:-
Language.properties
welcome_message =Welcome to Liferay is Easy
Language_fr.properties
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:-
Demo.java
Step 1:-Create portlet with properties file
Just create a same portlet as discuss in Internationalization (i18n) in liferay and create a Language_fr.properties file for french and Language.properties file for English in content folder.And paste this Content:-
Language.properties
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:-
Demo.java
Explanation:-
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:-
view.jsp
That's it you can deploy and check the output.You can check out video tutorial for the same.
Step 3:-Change the view
open view.jsp and paste this:-
view.jsp
That's it you can deploy and check the output.You can check out video tutorial for the same.
No comments:
Post a Comment