In Liferay we have one great advantage is that, we can use the same key to get the different values of particular word or key based upon the Locale(nothing but the language). This blog will help you using the different ways.
1.Directly using tag :-
<liferay-ui:message key="payment"/>
2.By using Stirng Variable :-
String checkout = LanguageUtil.get(portletConfig,themeDisplay.getLocale(),"payment");
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>
1.Directly using tag :-
<liferay-ui:message key="payment"/>
2.By using Stirng Variable :-
String checkout = LanguageUtil.get(portletConfig,themeDisplay.getLocale(),"payment");
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>