ZF-6612: Zend_Translate and automatic locale detection with directory scanning


I have the following code:

$locale = new Zend_Locale(Zend_Locale::BROWSER);

$translate = new Zend_Translate(
    array('scan' => Zend_Translate::LOCALE_DIRECTORY));
// setting the right locale
if ($translate->isAvailable($locale->getLanguage())) {
} else {

In my $path I have it and fr subdirectories.

When initializing Zend_Translate, an implicit setLocale is called with the user's preferred locale according to his browser's preferences. Here is the error message I get if my preferred language is 'en': {quote} Notice: The language 'en_US' has to be added before it can be used. in /home/eserra/ on line 317 Notice: No translation for the language 'en' available. in /home/eserra/ on line 330 {quote}

I think that, in case of scan option the automatic locale detection should be disabled. At the end of the scan process, if the locale coming from user's browser is found it could be set, otherwise I think that no notices should be generated, this allow the developer to provide fallback code as I did in my snippet.

My .02 $


Or you simply disable the notices when you know that you don't need them. See the 'disableNotices' option within the manual.

That's how the manual describes this usecase.