Search code examples
javaliferayliferay-6multilingualliferay-theme

Add language support in liferay theme


I am creating theme using liferay 6.2. I need to add language support in my theme. For this I try to add language portlet by using

$theme.language()

in portal_normal.vm. By this portlet is added to theme but it did not work. Also I tried by

     $velocityPortletPreferences.setValue("portletSetupShowBorders","false")
     <menu class="nav-horizontal" id="language-navigation">
         <ul>
             <li>$theme.runtime("82", "", $velocityPortletPreferences.toString())</li>
         </ul>
     </menu>
     $velocityPortletPreferences.reset()

Also I noticed that language portlet does not work for guest (unauthorized) user. The issue has been logged here.

My requirement is whenever guest user comes to site he can change the language and accordingly Theme/site pages/admin/web content should change to the respective language.

Can anyone suggest a workaround to develop this functionality?


Solution

  • I have achieved this by adding

                 <ul>
                    <li><a href="/en"+$theme_display.getURLCurrent() title="UK">UK</a></li>
                    <li><a href="/de"+$theme_display.getURLCurrent() title="Germen">Germen</a></li>
                  </ul>
    

    in portal_normal.vm file. For localizing footer, I created the Web content with german translation and add it in footer like this

    <footer id="footer" role="contentinfo">
    
            #set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
            #set ($portlet_id = '56')
            #set ($instance_id = "lw8tVGo0NyCB")
            #set ($my_portlet_id = "${portlet_id}_INSTANCE_${instance_id}")
            $theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
            $velocityPortletPreferences.reset() </footer>