In Liferay, you can add language key in liferay in JSP, Fragments, and Templates (e.g., FreeMarker) to make your application multilingual. Here’s how to do it in each case:
Adding Language Key in JSP
In a JSP file, you can use Liferay’s <liferay-ui:message>
tag to retrieve and display the language key value.
First you will have to import the liferay-ui
tag library.
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
You can use a language key in your JSP
<liferay-ui:message key="your-language-key" />
Adding Language Key in Fragment
In a Liferay Fragment, You can use the @liferay.langauge
method to access the language key.
[@liferay.language key="your-language-key" /]
Adding Language Key in widget template or web content template
In templates, You can use the languageUtil.get
or @liferay.langauge
method to access the language key.
${languageUtil.get(locale, "your-language-key")}
<@liferay.language key="your-language-key" />