Monday, July 6, 2015

Locale message in javascript of .jsp and in .js

As continue to my previous blog, sometimes we get requirement to display locale message in 'Notifications' or 'Alerts'. It is easy to diplay in jsp page in labels but how to display in alerts then the below is an example which will help you on this type of requirement.

example :-
.jsp code :-
 
function modeAlert(){
        alert("<liferay-ui:message key="payment"/>");
    }

.js code :- 

 Liferay.Language.get('key');

--------------------------------------------------------------------------

Path for Language properties file :-  src/content/Language_en_US.properties

Language_en_US.properties :-  ex: (Key : Vlaue)
  
  payment: Payment 

Language_ms_MY.properties :-  ex: (Key : Vlaue)

  payment: Pembayaran

When ever you use the above key(first way or second way) depending upon the current locale the value will be diplayed.

WEB-INF/Portlet.xml :- The entry in the portlet.xml is also mandatory then only you can able to see the values otherwise you can see only key as output.

<portlet>
<portlet-name>request</portlet-name>
<display-name>Request</display-name>
<portlet-class>com.Request</portlet-class>
<init-param>
</init-param>
<supports>
</supports>
<supported-locale>en_US</supported-locale>
<supported-locale>ms_MY</supported-locale>
<resource-bundle>content.Language</resource-bundle>
<portlet-info>
  </portlet-info>
 </portlet>

No comments:

Liferay DXP JNDI Data Source Cofiguration

 This Blog will help us to learn about the JNDI Data Source Configuration in Liferay DXP. We have tested this with Liferay 7.3 with Tomcat. ...