Language selector
There exist two different language selector viewlet bases for Plone
- Viewlet from vanilla Plone
- Viewlet from LinguaPlone - LinguaPlone has its own language selector which replaces the default Plone selector if LinguaPlone is installed
Source code references
- https://svn.plone.org/svn/plone/plone.app.i18n/trunk/plone/app/i18n/locales/browser/selector.py
- https://svn.plone.org/svn/plone/plone.app.i18n/trunk/plone/app/i18n/locales/browser/languageselector.pt
- http://svn.plone.org/svn/plone/Products.LinguaPlone/tags/2.4/Products/LinguaPlone/browser/selector.py
Making language flags point to different domains
It is often desirable to make the language selector point to a different domains for different languages. For example, search engines get confused by dynamic language switcher and will index switching links, messing up your site search results.
Below is an example where different top level domain links are hard coded to the language selector template:
<tal:language
tal:define="available view/available;
languages view/languages;
showFlags view/showFlags;">
<ul id="portal-languageselector"
tal:condition="python:available and len(languages)>=2">
<tal:language repeat="lang languages">
<li tal:define="code lang/code;
selected lang/selected"
tal:attributes="class python: selected and 'currentLanguage' or '';">
<a href=""
tal:condition="python:code =='fi'"
tal:define="flag lang/flag|nothing;
name lang/name"
tal:attributes="href string:http://www.twinapex.fi;
title name">
<tal:flag condition="python:showFlags and flag">
<img
width="14"
height="11"
alt=""
tal:attributes="src string:${view/portal_url}${flag};
title python: name;
class python: selected and 'currentItem' or '';" />
</tal:flag>
<tal:nonflag condition="python:not showFlags or not flag"
replace="name">language name</tal:nonflag>
</a>
<a href=""
tal:condition="python:code =='en'"
tal:define="flag lang/flag|nothing;
name lang/name"
tal:attributes="href string:http://www.twinapex.com;
title name">
<tal:flag condition="python:showFlags and flag">
<img
width="14"
height="11"
alt=""
tal:attributes="src string:${view/portal_url}${flag};
title python: name;
class python: selected and 'currentItem' or '';" />
</tal:flag>
<tal:nonflag condition="python:not showFlags or not flag"
replace="name">language name</tal:nonflag>
</a>
</li>
</tal:language>
</ul>
</tal:language>

Author: