Robert,

once again...

*) If you are using a auto locale you should not set it again afterwards.
Eigther you are doing like described in the manual using 'auto' and you need not to set the language afterwards OR you are using no language at all at creation and set if after initialization.

Using both like in your code is unnecesary and can lead to misbehaviour especially when you use two different automatted locales like in your code.

*) You set the locale to 'en' and then you do not want to have it set to 'en' ???
What do you want ???

*) You are composing the locale yourself which does not work the way you did it. Have you read the manual about Zend_Locale before you used it ??
Why are you converting the object to an string and then cut it ??
See getLanguage / getRegion / isLocale / getBrowser

You should debug your code to see what your browser really returns...
Firefox for example returns always all locales with 100% but in the order you entered them. So the question is what your browser returns, what languages are registered, and and and...
We can not just expect without having details.
Please inform yourself about basic ways of debugging. This will really help you.

Without any information it's just like driving blind on the roadway. ;-)

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

----- Original Message ----- From: "Robert Castley" <[EMAIL PROTECTED]> To: "Robert Castley" <[EMAIL PROTECTED]>; "Thomas Weidner" <[EMAIL PROTECTED]>
Sent: Saturday, March 22, 2008 11:40 PM
Subject: RE: [fw-general] Zend_Locale and browser detection question (ZF 1.5)


Hi Thomas,

I know I am a pain, but I have already tried everything and it still doesn't work as advertised. I must be missing something but I can't figure it out.

I have now modified my code as follows, so my question now is, is this OK?

   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);

       $locale = new Zend_Locale();

       $options = array('scan' => Zend_Translate::LOCALE_DIRECTORY);

       $translate = new Zend_Translate('csv', 'languages', 'auto',
$options);

       if (!array_key_exists(substr($locale->__toString(), 0, 2),
$translate->getList())) {
           Zend_Registry::get('logger')->info('Locale ' . $locale . 'not
found resetting to English');
           $translate->setLocale('en');
       } else {
           $translate->setLocale('browser');
       }

       Zend_Registry::set('Zend_Translate', $translate);
   }

This seems to set the locale to English if, for example I choose Catalan
which is not a translated language in my app.

Thanks for being patient with me :-)

- Robert

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

Robert,

as I already said within the issue you opened you must use 'auto' when you
use directory scanning instead of 'browser'.
For 2) I gave you already the solution
And 3) can not work... you are using different options in your example code
1 and 3 because you set no language to use, so it uses always the last
found.

Please do not re-ask already answered questions ;-)

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

----- Original Message -----
From: "Robert Castley" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, March 22, 2008 11:14 PM
Subject: [fw-general] Zend_Locale and browser detection question (ZF 1.5)


I currently have:

public function preDispatch(Zend_Controller_Request_Abstract $request)
   {
     $translate = new Zend_Translate('csv', 'languages', 'browser',
array('scan'=>Zend_Translate::LOCALE_DIRECTORY));
     $translate->setLocale('browser');
     Zend_Registry::set('Zend_Translate', $translate); }

If I don't use $translate->setLocale('browser'); it seems to display
the values of the last language file loaded.

A couple of things to note:

1) My language files are stored like so:

/languages
 -->en
   -->lang.en
 -->de
   -->lang.de
 -->fr
   -->lang.fr

2) If I set my browser to e.g. Cambodian(km) I will only see
messageIds in my view. How do I get this to default or downgrade to
English. In 1.0.4 using the addTranslation it use to downgrade through
the available languages sent by the browser i.e. if I had km -> es ->
en in my list it would display English.

3) If I cache the language files using:

   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', 'languages', null,
$options);

       Zend_Registry::set('Zend_Translate', $translate);
   }

Once the cache has expired I will always get the last language loaded
displayed until I refresh again i.e. it is not picking up the browser
locale.

Many thanks,

- Robert


______________________________________________________________________
__ 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