Question

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?

Was it helpful?

Solution 3

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>

OTHER TIPS

You can add the desired language as part of the URL: E.g. view one page on liferay.com in english: http://www.liferay.com/en/radio. Same page in german (well, the content is non-localized, but the navigation elements are): http://www.liferay.com/de/radio. This works also if you have more narrow definitions, e.g. with en_GB for british english.

In addendum to Olaf solution, you can add javascript snippet to the theme, something like this

var deutsch = "<a href='/de" + Liferay.currentURL + "'>De</a>";
var spain = "<a href='/es" + Liferay.currentURL + "'>Es</a>";
languagesDiv.html(deutsch + spain);

Below code work for me in liferay 6.2 community edition. I change then it in configuration show dropdown and added require language from settings.

<div >
$velocityPortletPreferences.setValue("portletSetupShowBorders", "false")
$velocityPortletPreferences.setValue("languageIds", "pt_BR,en_US")
$velocityPortletPreferences.setValue("displayStyle", "1")
$theme.runtime("82", "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top