Re: WO localization and accept-language header

Chuck Hill <[email protected]> Thu, 23 Apr 2009 09:57:39 -0700
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
On Apr 23, 2009, at 2:43 AM, Kasper Frederiksen wrote:

> WO reads a HTTP-request with header 'accept-language =
> ("no,da-DK;q=0.3")' and enterprets the languages Norwegian and Danish.
> A call to request.browserLanguages() gives '("Norwegian", "Danish")'.
>
> WO reads a HTTP-request with header 'accept-language =
> ("nn-NO,nb-NO;q=0.7,da-DK;q=0.3")' and interprets the languages as
> Danish only. A call to request.browserLanguages() gives '("Danish")'.
>
> 'nn-NO' and 'nb-NO' are the languages Norwegian(Ny Norsk) and  
> Norwegian(Bokmål).
>
> Is it true that WO does not recognize 'nb-NO' as Norwegian? ... is it
> possible it can learn?
>
> For now I have a solution where i overwrite createRequest on
> WOApplication and manually add 'no' to the accept-language header if I
> see 'nn-NO' or 'nb-NO'.

You should be able to do it with a WORequest subclass.  Wonder might  
already do this.  You can download our (GVC) frameworks from
http://www.gvcsitemaker.com/chill/gvc_frameworks

RequestUtilities class in GVCWOExtensions has code to deal with some  
of the accept-language data.  I am not sure that it works for this  
exact case, but it should be easy to modify to do so.

>      * Returns the browser languages from the accept-language header  
> ordered, and translated into
>      * longer names.  See humanReadableNameForISOName for how this  
> translation is done.
>      * Unlike the WORequest method of this name, country names are  
> included.  This
>      * allows the basic localization to handle different dialects.  
> The defaultLanguage() is included
>      * at the end if not specified in the request.  This ensures  
> that the user at least seems something
>      * intelligible (assuming it is defined in the default language).


Chuck

-- 
Chuck Hill             Senior Consultant / VP Development

Come to WOWODC'09 in San Fran this June!
http://www.wocommunity.org/wowodc09/