Hello,

I'm facing a problem using automatic language detection with Zend_Translate.
I'm using Zend_Application_Resource_Translate and here is my application.ini
:

...
resources.translate.adapter = ini
resources.translate.data = APPLICATION_PATH "/../languages"
resources.translate.options.scan = directory
...

I've got the following file hierarchy for languages directory :

languages/
    en/
        global.ini
    fr/
        global.ini

And here is my HTTP Accept-Language header :
HTTP_ACCEPT_LANGUAGE = "fr-fr,fr;q=0.8,en;q=0.5,en-us;q=0.3"

When global.ini in fr/ directory exists, no problem, my messageIds are
translated. But if I remove the fr/ directory and as a consequence french
language support to my application, Zend_Translate does not fallback to
English as expected due to my HTTP header. Instead, I've got these notices
(if I don't disable notices) :

   - *Notice*: The language 'fr_FR' has to be added before it can be used.
   in *[...]**\library\Zend\Translate\Adapter.php* on line *338*
   - *Notice*: No translation for the language 'fr' available. in *
   [...]\library\Zend\Translate\Adapter.php* on line *351*

After a rapid analysis in Zend_Translate_Adapter class, it seems that the 3
last lines of code in the constructor override the previously automatically
detected locale in _addTranslationData method :

public function __construct($data = null, $locale = null, array $options =
array())
{
    ...
    if ($this->getLocale() !== (string) $locale) {
        $this->setLocale($locale);
    }
}

Is this a bug or do I misuse Zend_Translate automatic language detection
feature ?

Thanks in advance for your help.

-- 
Loïc Frering
http://losohome.wordpress.com/
[email protected]

Reply via email to