Issues

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

Issue Type: Bug Created: 2013-02-21T15:14:14.000+0000 Last Updated: 2013-04-05T16:06:58.000+0000 Status: Closed Fix version(s): Reporter: Tim Koop (magmatic) Assignee: None Tags: - Zend_Translate

Related issues: Attachments:

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)

<pre class="highlight">
    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:

<pre class="highlight">
    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

Posted by Ralph Schindler (ralph) on 2013-04-05T16:06:58.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts