Hello,

after one and a half days of reading manual and forums, and testing many
configuartions, I dare to ask the mailing list now.

If I take the source code from the manual
(http://framework.zend.com/manual/en/zend.translate.using.html, 46.9.), it
does not act like described there.

- The output in my browser is the following:
de_AT=1;fr=1;en_US=0.8
it_IT: italiano
it_IT: italiano
de: deutsch
de: deutsch

- After what the manual says, I would have expected that:
de_AT=1;fr=1;en_US=0.8
: key
en: english
de: deutsch
it_IT: italiano

- In my bootstrap, there is nothing about Zend_Translate or Zend_locale at
all. For testing purposes I just put the code from the manual into my
IndexController.

- My browser (firefox) is set to accept de_AT, fr, en_US.

- I put the neccessary translation files (PHP arrays) in APPLICATION_PATH .
'/../translations/' and named them it.php, ru.php, en.php es.php and de.php.
They look like this: 
<?php
return array(
    'key' => 'english'
);

-My IndexController contains the code from the manual plus a few echo's from
me. Here it is: 
// Let's expect the browser returns this language settings
// HTTP_ACCEPT_LANGUAGE = "de_AT=1;fr=1;en_US=0.8";
echo $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '<br />';

// Example 1:
$translate = new Zend_Translate("gettext", "\my_it.mo", "it_IT");
$translate->addTranslation("\my_es.mo","es_UG");
// no fitting language found, return the messageid
echo $translate->getLocale() . ': ';
echo $translate->_('key') . '<br />';

// Example 2:
$translate = new Zend_Translate("gettext", "\my_en.mo", "en_US");
$translate->addTranslation("\my_it.mo","it_IT");
// best found fitting language is "en_US"
echo $translate->getLocale() . ': ';
echo $translate->_('key') . '<br />';

// Example 3:
$translate = new Zend_Translate("gettext", "\my_it.mo", "it_IT");
$translate->addTranslation("\my_de.mo","de");
// best found fitting language is "de" because "de_AT" will be
// degraded to "de"
echo $translate->getLocale() . ': ';
echo $translate->_('key') . '<br />';

// Example 4:
$translate = new Zend_Translate("gettext", "\my_it.mo", "it_IT");
$translate->addTranslation("\my_ru.mo","ru");
$translate->setLocale("it_IT");
$translate->addTranslation("\my_de.mo","de");
// returns "it_IT" as translation source
echo $translate->getLocale() . ': ';
echo $translate->_('key') . '<br />';

I use Zend Framework 1.6.2, PHP 5.2.6 on Ubuntu with LAMPP.

Could anyone please tell me, what is the problem here?

Best regards,
Jörg Hambuch
-- 
View this message in context: 
http://www.nabble.com/Zend_Translate-automatic-language-detection-tp20340272p20340272.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to