[opencms-dev] Multilingual sites - Browser's AcceptedLanguages

Peter Olsson s.o.peter.olsson at telia.com
Tue Jul 11 13:24:18 CEST 2006


Hi,

I'm trying to use OpenCms for a web site with several languages. It has 
English as the base language and then we have translations for different 
parts and pages. At present the web site have approximately 12 languages.

At this point I have one problem to start with:

In the OpenCms 6 book (page 75) Matt Butcher writes that "Based on the 
browser's language settings, the end user will be served whichever 
language they prefer!". I also believe this has worked in some older 
version I have tried before but now I cant get it to work this way.

In the code (6.2.1) I have found the handler for this in the class 
org.opencms.i18n.CmsDefaultLocaleHandler. It retrieves the locale from 
1) the parameter __locale if present, 2) it uses the locale for the 
requested resource if defined and if it is one of the locale defined in 
the opencms-system.xml file, 3) the first locale in opencms-system.xml, 
and 4) the default locale for OpenCms (=English). If I remember coorect 
this is at least approximately what happends but the thing is that there 
is nothing that look at the AcceptedLanguages.

Looking in Alkacon's Technical slide presentation 
(http://www.opencms.org/export/download/alkacon/Alkacon_OpenCms_6_Technical.pdf) 
it says that "The selected language is controlled by the configured 
locale handler: - default: configured locale property on folder - 
alternative: use browser locale".

The locale handler can be defined in opencms-system.xml and the default 
one is org.opencms.i18n.CmsDefaultLocaleHandler. There is a class 
org.opencms.i18n.CmsAcceptLanguageHeaderParser but no LocaleHandler that 
uses it. At least I can't find one.

Is there a class that implements I_CmsLocaleHandler and handles browser 
locale or do I have to write one?

Or how can this be done?


/Peter Olsson



More information about the opencms-dev mailing list