lib/ezi18n/classes/eztstranslator.php
function handleMessageNode( $contextName, $message )
    {
        $source = null;
        $translation = null;
        $comment = null;
        $message_children = $message->childNodes;
        for( $i = 0; $i < $message_children->length; $i++ )
        {
            $message_child = $message_children->item( $i );
            if ( $message_child->nodeType == XML_ELEMENT_NODE )
            {
                $childName = $message_child->tagName;
                if ( $childName  == "source" )
                {
                    if ( $message_child->childNodes->length > 0 )
                    {
                        $source = '';
                        foreach ( $message_child->childNodes as $textEl )
                        {
                            if ( $textEl instanceof DOMText )
                            {
                                $source .= $textEl->nodeValue;
                            }
                            else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
                            {
                                $source .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
                            }
                        }
                    }
                }
                else if ( $childName == "translation" )
                {
                    if ( $message_child->childNodes->length > 0 )
                    {
                        $translation = '';
                        foreach ( $message_child->childNodes as $textEl )
                        {
                            if ( $textEl instanceof DOMText )
                            {
                                $translation .= $textEl->nodeValue;
                            }
                            else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
                            {
                                $translation .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
                            }
                        }
                    }
                }
                else if ( $childName == "comment" )
                {
                    $comment_el = $message_child->firstChild;
                    $comment = $comment_el->nodeValue;
                }
                else if ( $childName == "translatorcomment" )
                {
                    //Ignore it.
                }
                else if ( $childName == "location" )
                {
                    //Handle location element. No functionality yet.
                }
                else
                    eZDebug::writeError( "Unknown element name: " . $childName, __METHOD__ );
            }
        }
        if ( $source === null )
        {
            eZDebug::writeError( "No source name found, skipping message in context '{$contextName}'", __METHOD__ );
            return false;
        }
        if ( $translation === null ) // No translation provided, then take the source as a reference
        {
//             eZDebug::writeError( "No translation, skipping message", __METHOD__ );
            $translation = $source;
        }
        /* we need to convert ourselves if we're using libxml stuff here */
        if ( $message instanceof DOMElement )
        {
            $codec = eZTextCodec::instance( "utf8" );
            $source = $codec->convertString( $source );
            $translation = $codec->convertString( $translation );
            $comment = $codec->convertString( $comment );
        }

        $this->insert( $contextName, $source, $translation, $comment );
        return true;
    }
function handleMessageNode( $contextName, $message )
    {
        $source = null;
        $translation = null;
        $comment = null;
        $message_children = $message->childNodes;
        for( $i = 0; $i < $message_children->length; $i++ )
        {
            $message_child = $message_children->item( $i );
            if ( $message_child->nodeType == XML_ELEMENT_NODE )
            {
                $childName = $message_child->tagName;
                if ( $childName  == "source" )
                {
                    if ( $message_child->childNodes->length > 0 )
                    {
                        $source = '';
                        foreach ( $message_child->childNodes as $textEl )
                        {
                            if ( $textEl instanceof DOMText )
                            {
                                $source .= $textEl->nodeValue;
                            }
                            else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
                            {
                                $source .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
                            }
                        }
                    }
                }
                else if ( $childName == "translation" )
                {
                    if ( $message_child->childNodes->length > 0 )
                    {
                        $translation = '';
                        foreach ( $message_child->childNodes as $textEl )
                        {
                            if ( $textEl instanceof DOMText )
                            {
                                $translation .= $textEl->nodeValue;
                            }
                            else if ( $textEl instanceof DOMElement && $textEl->tagName == 'byte' )
                            {
                                $translation .= chr( intval( '0' . $textEl->getAttribute( 'value' ) ) );
                            }
                        }
                    }
                }
                else if ( $childName == "comment" )
                {
                    $comment_el = $message_child->firstChild;
                    $comment = $comment_el->nodeValue;
                }
                else if ( $childName == "translatorcomment" )
                {
                    //Ignore it.
                }
                else if ( $childName == "location" )
                {
                    //Handle location element. No functionality yet.
                }
                else
                    eZDebug::writeError( "Unknown element name: " . $childName, __METHOD__ );
            }
        }
        if ( $source === null )
        {
            eZDebug::writeError( "No source name found, skipping message in context '{$contextName}'", __METHOD__ );
            return false;
        }
        if ( $translation === null ) // No translation provided, then take the source as a reference
        {
//             eZDebug::writeError( "No translation, skipping message", __METHOD__ );
            $translation = $source;
        }
        /* we need to convert ourselves if we're using libxml stuff here */
        if ( $message instanceof DOMElement )
        {
            $codec = eZTextCodec::instance( "utf8" );
            $source = $codec->convertString( $source );
            $translation = $codec->convertString( $translation );
            $comment = $codec->convertString( $comment );
        }

        $this->insert( $contextName, $source, $translation, $comment );
        return true;
    }
function handleMessageNode ( $ contextName , $ message ) { $ source = null ; $ translation = null ; $ comment = null ; $ message_children = $ message -> childNodes ; for ( $ i = 0 ; $ i < $ message_children -> length ; $ i ++ ) { $ message_child = $ message_children -> item ( $ i ) ; if ( $ message_child -> nodeType == XML_ELEMENT_NODE ) { $ childName = $ message_child -> tagName ; if ( $ childName == "source" ) { if ( $ message_child -> childNodes -> length > 0 ) { $ source = '' ; foreach ( $ message_child -> childNodes as $ textEl ) { if ( $ textEl instanceof DOMText ) { $ source .= $ textEl -> nodeValue ; } else if ( $ textEl instanceof DOMElement && $ textEl -> tagName == 'byte' ) { $ source .= chr ( intval ( '0' . $ textEl -> getAttribute ( 'value' ) ) ) ; } } } } else if ( $ childName == "translation" ) { if ( $ message_child -> childNodes -> length > 0 ) { $ translation = '' ; foreach ( $ message_child -> childNodes as $ textEl ) { if ( $ textEl instanceof DOMText ) { $ translation .= $ textEl -> nodeValue ; } else if ( $ textEl instanceof DOMElement && $ textEl -> tagName == 'byte' ) { $ translation .= chr ( intval ( '0' . $ textEl -> getAttribute ( 'value' ) ) ) ; } } } } else if ( $ childName == "comment" ) { $ comment_el = $ message_child -> firstChild ; $ comment = $ comment_el -> nodeValue ; } else if ( $ childName == "translatorcomment" ) { //Ignore it. } else if ( $ childName == "location" ) { //Handle location element. No functionality yet. } else eZDebug :: writeError ( "Unknown element name: " . $ childName , __METHOD__ ) ; } } if ( $ source === null ) { eZDebug :: writeError ( "No source name found, skipping message in context '{$contextName}'" , __METHOD__ ) ; return false ; } if ( $ translation === null ) // No translation provided, then take the source as a reference { //             eZDebug::writeError( "No translation, skipping message", __METHOD__ ); $ translation = $ source ; } /* we need to convert ourselves if we're using libxml stuff here */ if ( $ message instanceof DOMElement ) { $ codec = eZTextCodec :: instance ( "utf8" ) ; $ source = $ codec -> convertString ( $ source ) ; $ translation = $ codec -> convertString ( $ translation ) ; $ comment = $ codec -> convertString ( $ comment ) ; } $ this -> insert ( $ contextName , $ source , $ translation , $ comment ) ; return true ; }
Handles a translation message DOM node
@param string $contextName
@param DOMNode $message
Handles a translation message DOM node