ZF-11567: automatic detection of locales based on directory structure fails

Description

version 1.11.9 seems to haven introduced a bug in the automatic detection of locales via directory scanning.

I use the following setup:

The default locale is set to "en"

Zend_Translate is configured with the following options:


$translate = new Zend_Translate(
  array(
    'adapter' => 'gettext',
    'content' => APPLICATION_PATH . "/locale",
    'scan'    => Zend_Translate::LOCALE_DIRECTORY,
  )
);
Zend_Registry::set('Zend_Translate', $translate);

The directory structure containing the gettext files is as follows

 
APPLICATION_PATH
  locale
    de
      LC_MESSAGES
        messages.mo
    en
      LC_MESSAGES
        messages.mo
    fr
      LC_MESSAGES
        messages.mo

When i upgraded from version 1.11.8 to 1.11.9 only one locale was fetched. It was recognized as the default locale ("en" in my case), although it contained the translation strings of the last locale in the content-directory.

The problem seems to be caused by the new code on line 248 in Zend_Translator_Adapter.

The iterator seems to contain only files and no directories, so the different locales never get identified and correctly added.

Based on the code from version 1.11.8 i added the RecursiveIteratorIterator::SELF_FIRST parameter to the RecursiveIteratorIterator constructor. This seems to have solved the problem.

Comments

This issue is now fixed by r24268

Thanks a lot for the input.

Fixed implementation with GH-259 See ZF-11546 for details