Search code examples
liferayliferay-6

Can we have language define per user or group or org?


I wish to check whether we can restrict the supported languages listed in the language portlet based on the user organization or group.

We have a page with the language portlet which is configured with the languages "English", "French", "German" etc

We have users:

  • German users

    • Belong to org1 from Germany
    • When this type of user visits our page, he should see "English" and "Germin" in the language portlet only.
  • Other users

    • Belong to org2 from global ops
    • When this type of user visits our page, he should see all configured languages.

Can we achieve this with native Liferay or do we need to use a hook to achieve it?


Solution

  • As the language portlet uses the portlet preferences to store the selected languages (see /html/portlet/language/init.jsp) and that portlet declares preferences-owned-by-group (see /WEB-INF/liferay-portlet.xml) it means that all users see the same list of languages.

    If you want to change that you will either have to write a hook (make the necessary modifications in /html/portlet/language/init-ext.jsp then), create your own portlet, or you implement that feature in your theme. The later is a common scenario anyway, if the demanded designs don't match the ones provided by the language portlet.