Brilliant!!!!!! Now working.  Also I have learnt something about Language
Quality of which I wasn't aware of before.

Thank you for being patient with me and also taking the time to respond.  It
really is very much appreciated!

Cheers,

- Robert 

-----Original Message-----
From: Thomas Weidner [mailto:[EMAIL PROTECTED] 
Sent: 23 March 2008 14:40
To: Robert Castley; [email protected]
Subject: Re: [fw-general] Zend_Locale and browser detection question (ZF
1.5)

Robert,

Your expectation is not right.

Your browser has set 2 languages at the same quality.
French and german are using both 70% quality and only english is at 30%
quality.
Your browser says that he has french and german at the same level so there
is no order in them.

As I already said there is actually no rerouting for languages. So if a
language is not available it is not automatically rerouted to another
language.
Also here your expectation is not true.

You set "german" and "english"... but you ask for "french"...
As french is not available the messageid is returned instead.

If you ask for a language which is not available and do not want the
messageid to be used you must reroute to the minimum used language.
A simple

if (!$translate->isAvailabe($locale)) {
    $translate->setLocale($otherLocale);
}

does the trick.

Greetings
Thomas Weidner, I18N Team Leader
http://www.thomasweidner.com

----- Original Message -----
From: "Robert Castley" <[EMAIL PROTECTED]>
To: "Thomas Weidner" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Sunday, March 23, 2008 1:08 PM
Subject: RE: [fw-general] Zend_Locale and browser detection question (ZF
1.5)


>I must be having a (several) blonde moment(s), I have been over the 
>docs for  translate and locale and I am still not getting it:
>
> I have created a debug trace of the results from using my current method:
>
> <BEGIN>
> Return value of new Zend_Locale('auto'): fr_FR
>
> _SERVER["HTTP_ACCEPT_LANGUAGE"]=fr-fr,de-de;q=0.7,en-gb;q=0.3
>
> Registry contains:
> Zend_Translate Object
> (
>    [_adapter:private] => Zend_Translate_Adapter_Csv Object
>        (
>            [_automatic:private] => 1
>            [_options:protected] => Array
>                (
>                    [clear] =>
>                    [scan] =>
>                    [locale] => auto
>                    [separator] => ;
>                )
>
>            [_translate:protected] => Array
>                (
>                    [de] => Array
>                        (
>                            [helloWorld] => Hallo Welt
>                        )
>
>                    [en] => Array
>                        (
>                            [helloWorld] => Hello World!
>                        )
>
>                )
>
>        )
>
> )
> Display getList():
> Array
> (
>    [de] => de
>    [en] => en
> )
> Translate helloWorld: helloWorld
> <END>
>
> You can see from the above that I have set my browser language 
> preference to be French then German and finally English.  I am 
> expecting Zend_Translate to select German as I currently don't have a 
> French translation file.  What I get is the messageId only.
>
> The code I am using is:
>
>    public function preDispatch(Zend_Controller_Request_Abstract $request)
>    {
>        $frontendOptions = array('lifetime' => 7200);
>        $backendOptions = array('cache_dir' => 
> Zend_Registry::get('config')->general->sessionSavePath);
>        $cache = Zend_Cache::factory('Page', 'File', $frontendOptions, 
> $backendOptions);
>        Zend_Translate::setCache($cache);
>
>        $options = array('scan' => Zend_Translate::LOCALE_DIRECTORY);
>
>        $translate = new Zend_Translate('csv', 'lang', 'auto', 
> $options);
>
>        Zend_Registry::set('Zend_Translate', $translate);
>    }
>
> If I run the test again and set the browser to use German my trace 
> gives
> me:
>
> <BEGIN>
> Return value of new Zend_Locale('auto'): de_DE
>
> _SERVER["HTTP_ACCEPT_LANGUAGE"]=de-de,fr-fr;q=0.7,en-gb;q=0.3
>
> Registry contains:
> Zend_Translate Object
> (
>    [_adapter:private] => Zend_Translate_Adapter_Csv Object
>        (
>            [_automatic:private] => 1
>            [_options:protected] => Array
>                (
>                    [clear] =>
>                    [scan] =>
>                    [locale] => auto
>                    [separator] => ;
>                )
>
>            [_translate:protected] => Array
>                (
>                    [de] => Array
>                        (
>                            [helloWorld] => Hallo Welt
>                        )
>
>                    [en] => Array
>                        (
>                            [helloWorld] => Hello World!
>                        )
>
>                )
>
>        )
>
> )
> Display getList():
> Array
> (
>    [de] => de
>    [en] => en
> )
> Translate helloWorld: Hallo Welt
> <END>
>
> This is correct and as expected.
>
> Why won't my code + Zend_Translate downgrade through the languages my 
> browser sends?  Please help, I am now on my knees begging :-)
>
>
>
> -----Original Message-----
> From: Thomas Weidner [mailto:[EMAIL PROTECTED]
> Sent: 22 March 2008 23:43
> To: Robert Castley; [email protected]
> Subject: Re: [fw-general] Zend_Locale and browser detection question 
> (ZF
> 1.5)
>
> Robert,
>
> as short summary:
>
> *) Delete the else tree. Its not needed as described before.
> *) Look at your array_key_exists clause... it's not doing what you 
> expect it to do.
>
>
> ________________________________________________________________________
> This email has been scanned for all known viruses by the MessageLabs Email

> Security Service and the Macro 4 plc internal virus protection system.
> ________________________________________________________________________ 


________________________________________________________________________
This email has been scanned for all known viruses by the MessageLabs Email
Security Service and the Macro 4 plc internal virus protection system.
________________________________________________________________________


________________________________________________________________________
This email has been scanned for all known viruses by the MessageLabs Email 
Security Service and the Macro 4 plc internal virus protection system.
________________________________________________________________________

Reply via email to