Site icon Pro Liferay

Liferay Language Properties Hook Development

language properties hook


The main purpose of Liferay Language Properties Hook is to override liferay default language properties. Liferay Portal uses lots of keys from different language properties files. This hook is extremely simple to develop.  By default Liferay Portal comes with 47 language properties files. If we want to change any message key of these properties files then we can create Language Properties Hook


Steps to follow

Step 1: Create Liferay Plugin project of type Hook. Consider that we have created the below project with name language-hook.

Step 2: Open liferay-hook.xml. The empty file look like this

<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">

<hook>

</hook>

Step 3: Go to Liferay source code under /portal-impl/src/content directory. Consider that we want to change Language_en.properties file. Find out what are the keys that you want to change. 

Step 4: Create same file Language_en.properties in content folder. 

 

 Step 5: Add below line in liferay-hook.xml

<language-properties>content/Language_en.properties</language-properties>

Finally  liferay-hook.xml should look like 

<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">

<hook>
    <language-properties>content/Language_en.properties</language-properties>
</hook>

 Step 6: Change the necessary keys in Language_en.properties of the hook. Keep in mind override only those key which are necessary. Don’t copy past the whole content from the source code to this file. 

Step 7: Deploy

Note: We can override multiple properties file.

Download Source Code 

Exit mobile version