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.
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.
________________________________________________________________________