protected function _addMessage(array &$messages, array $item)
    {
        if (empty($item['ids']['singular']) && empty($item['ids']['plural'])) {
            return;
        }

        $singular = stripcslashes($item['ids']['singular']);
        $context = isset($item['context']) ? $item['context'] : null;
        $translation = $item['translated'];

        if (is_array($translation)) {
            $translation = $translation[0];
        }

        $translation = stripcslashes($translation);

        if ($context !== null && !isset($messages[$singular]['_context'][$context])) {
            $messages[$singular]['_context'][$context] = $translation;
        } elseif (!isset($messages[$singular]['_context'][''])) {
            $messages[$singular]['_context'][''] = $translation;
        }

        if (isset($item['ids']['plural'])) {
            $plurals = $item['translated'];
            // PO are by definition indexed so sort by index.
            ksort($plurals);

            // Make sure every index is filled.
            end($plurals);
            $count = key($plurals);

            // Fill missing spots with an empty string.
            $empties = array_fill(0, $count + 1, '');
            $plurals += $empties;
            ksort($plurals);

            $plurals = array_map('stripcslashes', $plurals);
            $key = stripcslashes($item['ids']['plural']);

            if ($context !== null) {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
            } else {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
            }
        }
    }
protected function _addMessage(array &$messages, array $item)
    {
        if (empty($item['ids']['singular']) && empty($item['ids']['plural'])) {
            return;
        }

        $singular = stripcslashes($item['ids']['singular']);
        $context = isset($item['context']) ? $item['context'] : null;
        $translation = $item['translated'];

        if (is_array($translation)) {
            $translation = $translation[0];
        }

        $translation = stripcslashes($translation);

        if ($context !== null && !isset($messages[$singular]['_context'][$context])) {
            $messages[$singular]['_context'][$context] = $translation;
        } elseif (!isset($messages[$singular]['_context'][''])) {
            $messages[$singular]['_context'][''] = $translation;
        }

        if (isset($item['ids']['plural'])) {
            $plurals = $item['translated'];
            // PO are by definition indexed so sort by index.
            ksort($plurals);

            // Make sure every index is filled.
            end($plurals);
            $count = key($plurals);

            // Fill missing spots with an empty string.
            $empties = array_fill(0, $count + 1, '');
            $plurals += $empties;
            ksort($plurals);

            $plurals = array_map('stripcslashes', $plurals);
            $key = stripcslashes($item['ids']['plural']);

            if ($context !== null) {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
            } else {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
            }
        }
    }
protected function _addMessage ( array & $ messages , array $ item ) { if ( empty ( $ item [ 'ids' ] [ 'singular' ] ) && empty ( $ item [ 'ids' ] [ 'plural' ] ) ) { return ; } $ singular = stripcslashes ( $ item [ 'ids' ] [ 'singular' ] ) ; $ context = isset ( $ item [ 'context' ] ) ? $ item [ 'context' ] : null ; $ translation = $ item [ 'translated' ] ; if ( is_array ( $ translation ) ) { $ translation = $ translation [ 0 ] ; } $ translation = stripcslashes ( $ translation ) ; if ( $ context !== null && ! isset ( $ messages [ $ singular ] [ '_context' ] [ $ context ] ) ) { $ messages [ $ singular ] [ '_context' ] [ $ context ] = $ translation ; } elseif ( ! isset ( $ messages [ $ singular ] [ '_context' ] [ '' ] ) ) { $ messages [ $ singular ] [ '_context' ] [ '' ] = $ translation ; } if ( isset ( $ item [ 'ids' ] [ 'plural' ] ) ) { $ plurals = $ item [ 'translated' ] ; // PO are by definition indexed so sort by index. ksort ( $ plurals ) ; // Make sure every index is filled. end ( $ plurals ) ; $ count = key ( $ plurals ) ; // Fill missing spots with an empty string. $ empties = array_fill ( 0 , $ count + 1 , '' ) ; $ plurals += $ empties ; ksort ( $ plurals ) ; $ plurals = array_map ( 'stripcslashes' , $ plurals ) ; $ key = stripcslashes ( $ item [ 'ids' ] [ 'plural' ] ) ; if ( $ context !== null ) { $ messages [ Translator :: PLURAL_PREFIX . $ key ] [ '_context' ] [ $ context ] = $ plurals ; } else { $ messages [ Translator :: PLURAL_PREFIX . $ key ] [ '_context' ] [ '' ] = $ plurals ; } } }
Saves a translation item to the messages.

@param array $messages The messages array being collected from the file
@param array $item The current item being inspected
@return void
Saves a translation item to the messages .