Liferay Language Properties Hook Development

language properties hook


aimThe 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.

hook-project

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. 

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 

About The Author

1 thought on “Liferay Language Properties Hook Development”

  1. Pingback: Basics of Liferay Hook Development - Pro Liferay

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
%d