Changing language negotiation strategy
Purpose
For multilingual sites it's often needed to serve the content in a certain language determined by many factors. This document describes how one can tailor Plone to handle different situations.
Options
Plone control panel has some settings for the site language. More advanced language negotiation settings can be found from Zope Management Interface, portal_languages tool.
Currently (Plone 3.1) the following options exists :
- Use language codes in URL path for manual override = e.g. http://mysite/en/content = English, http://mysite/fi/content = Finnish
- Use cookie for manual override = store language setting in the cookie - this is prerequisite for the on-site language switching menu
- Use virtual host name of site = top level domain identifier determines the initial language, e.g. mysite.fi = Finnish and mysite.uk = English. Top level domain -> language mappings are determined in the file plone/i18n/locales/cctld.py and there is no way to change them without patching Plone.
- Use browser language request negotiation = use language the same language as in the visitor's browser user interface
Plone negotiates language in PloneLanguageTool.LanguageTool and PlacelessTranslationService.Negotiator modules. Besides options available in portal_languages in Zope Management Interface, there is no through-the-web way to change the strategy. To reach beyond options available in portal_language settings, you need to create a custom product which pokes PloneLanguageTool or PlacelessTranslationService internals.
Virtual hosts and top level domain names
If you want to support Top Level Domain (TLD) based language
negotiation and you are using Apache virtual hosts, be sure that your
virtual host settings are configured to forward the relevant domain
correctly:
Wrong:
ProxyPass / http://localhost:8080/VirtualHostBase/http/mysite.fi:80/archred/VirtualHostRoot/
This results to having localhost as TLD.
Right:
ProxyPass / http://mysite.fi:8080/VirtualHostBase/http/mysite.fi:80/archred/VirtualHostRoot/
This setting also affects the Apache proxy configuration in
/etc/apache2/mods-enabled/proxy.conf. If Apache proxy security is
picky, you might need to enlist public IP addresses of your sites in the allowed proxys.
For the future
Plone 3.1 does *not* user Zope 3 (Five) facilities to negotiate the user language when the user enters the site for the first time. All code files in plone.i18n.negotiator are just decoy and not utilized. This will change in the future.
