Issues

ZF-12528: The gettext Translate adapter does not translate a singular/plural phrase if the singular id equals the plural id

Description

In your php code, when you want to translate a phrase that could be singular or plural, you specify the singular id, the plural id, and the count. If the singular id exactly equals the plural id, it won't work because of a little bug in {{Zend_Translate_Adapter_Gettext}}.

Zend Translate uses an adapter called {{Zend_Translate_Adapter_Gettext}}. When this class reads in translation data in function {{_loadTranslationData()}}, from a .mo file, it does it mostly correctly:

The existing code: (starting from line 125 or so)


    if ((count($original) > 1) && (count($translate) > 1)) {
        $this->_data[$locale][$original[0]] = $translate;
        array_shift($original);
        foreach ($original as $orig) {
            $this->_data[$locale][$orig] = '';
        }
    } else {
        $this->_data[$locale][$original[0]] = $translate[0];
    }

This code works:


    if ((count($original) > 1) && (count($translate) > 1)) {
        $originalSingular = $original[0];
        foreach ($original as $orig) {
            $this->_data[$locale][$orig] = '';
        }
        $this->_data[$locale][$originalSingular] = $translate;
    } else {
        $this->_data[$locale][$original[0]] = $translate[0];
    }

Comments

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/58