[opencms-dev] Multilingual sites - Browser's AcceptedLanguages
Peter Olsson
s.o.peter.olsson at telia.com
Thu Jul 13 19:05:10 CEST 2006
Hi,
I found an earlier posting about this with the code for an alternative
LocaleHandler
(http://mail.opencms.org/pipermail/opencms-dev/2004q4/014031.html) which
gives the behavior I want. That is, the locale from the Accept-Language
setting of the browser is used if it is one of the configured languages.
I also get the functionality for the user to set the preferred language
explicitly.
But is this the right path to go?
Or can this be done in some other way?
I also get an automatic fallback if there is no translation of a
specific element in the preferred language of a page. That is, the
elements that are not translated will be in English.
/Peter
Peter Olsson wrote:
> 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
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
More information about the opencms-dev
mailing list