This repository has been archived by the owner. It is now read-only.

The gettext Translate adapter does not translate a singular/plural phrase if the singular id equals the plural id #58

Closed
zfbot opened this Issue Apr 5, 2013 · 2 comments

Comments

Projects
None yet
3 participants
@zfbot

zfbot commented Apr 5, 2013

Jira Information

Original Issue:ZF-12528
Issue Type:Bug
Reporter:Tim Koop
Created:02/21/13
Assignee:
Components:Zend_Translate

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];
    }
@zfbot

This comment has been minimized.

Show comment
Hide comment
@zfbot

zfbot Apr 5, 2013

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF-12528

Known GitHub users mentioned in the original message or comment:

zfbot commented Apr 5, 2013

This issue was ported from the ZF2 Jira Issue Tracker at
http://framework.zend.com/issues/browse/ZF-12528

Known GitHub users mentioned in the original message or comment:

@fisharebest

This comment has been minimized.

Show comment
Hide comment
@fisharebest

fisharebest Aug 30, 2013

This is a duplicate of #66 - for which a patch is available.

This is a duplicate of #66 - for which a patch is available.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.