classes/phing/filters/TranslateGettext.php
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        // Make sure correct params/attribs have been set
        $this->checkAttributes();

        $buffer = $this->in->read($len);
        if ($buffer === -1) {
            return -1;
        }

        // Setup the locale/gettext environment
        $this->initEnvironment();


        // replace any occurrences of _("") or gettext("") with
        // the translated value.
        //
        // ([^\w]|^)_\("((\\"|[^"])*)"\)
        //  --$1---      -----$2----
        //                 ---$3--  [match escaped quotes or any char that's not a quote]
        //
        // also match gettext() -- same as above

        $buffer = preg_replace_callback(
            '/(\W|^)_\("((\\\"|[^"])*)"\)/',
            [$this, 'xlateStringCallback'],
            $buffer
        );
        $buffer = preg_replace_callback(
            '/(\W|^)gettext\("((\\\"|[^"])*)"\)/',
            [$this, 'xlateStringCallback'],
            $buffer
        );

        // Check to see if there are any _('') calls and flag an error

        // Check to see if there are any unmatched gettext() calls -- and flag an error

        $matches = [];
        if (preg_match('/(\W|^)(gettext\([^\)]+\))/', $buffer, $matches)) {
            $this->log("Unable to perform translation on: " . $matches[2], Project::MSG_WARN);
        }

        $this->restoreEnvironment();

        return $buffer;
    }
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

        // Make sure correct params/attribs have been set
        $this->checkAttributes();

        $buffer = $this->in->read($len);
        if ($buffer === -1) {
            return -1;
        }

        // Setup the locale/gettext environment
        $this->initEnvironment();


        // replace any occurrences of _("") or gettext("") with
        // the translated value.
        //
        // ([^\w]|^)_\("((\\"|[^"])*)"\)
        //  --$1---      -----$2----
        //                 ---$3--  [match escaped quotes or any char that's not a quote]
        //
        // also match gettext() -- same as above

        $buffer = preg_replace_callback(
            '/(\W|^)_\("((\\\"|[^"])*)"\)/',
            [$this, 'xlateStringCallback'],
            $buffer
        );
        $buffer = preg_replace_callback(
            '/(\W|^)gettext\("((\\\"|[^"])*)"\)/',
            [$this, 'xlateStringCallback'],
            $buffer
        );

        // Check to see if there are any _('') calls and flag an error

        // Check to see if there are any unmatched gettext() calls -- and flag an error

        $matches = [];
        if (preg_match('/(\W|^)(gettext\([^\)]+\))/', $buffer, $matches)) {
            $this->log("Unable to perform translation on: " . $matches[2], Project::MSG_WARN);
        }

        $this->restoreEnvironment();

        return $buffer;
    }
public function read ( $ len = null ) { if ( ! $ this -> getInitialized ( ) ) { $ this -> _initialize ( ) ; $ this -> setInitialized ( true ) ; } // Make sure correct params/attribs have been set $ this -> checkAttributes ( ) ; $ buffer = $ this -> in -> read ( $ len ) ; if ( $ buffer === - 1 ) { return - 1 ; } // Setup the locale/gettext environment $ this -> initEnvironment ( ) ; // replace any occurrences of _("") or gettext("") with // the translated value. // // ([^\w]|^)_\("((\\"|[^"])*)"\) //  --$1---      -----$2---- //                 ---$3--  [match escaped quotes or any char that's not a quote] // // also match gettext() -- same as above $ buffer = preg_replace_callback ( '/(\W|^)_\("((\\\"|[^"])*)"\)/' , [ $ this , 'xlateStringCallback' ] , $ buffer ) ; $ buffer = preg_replace_callback ( '/(\W|^)gettext\("((\\\"|[^"])*)"\)/' , [ $ this , 'xlateStringCallback' ] , $ buffer ) ; // Check to see if there are any _('') calls and flag an error // Check to see if there are any unmatched gettext() calls -- and flag an error $ matches = [ ] ; if ( preg_match ( '/(\W|^)(gettext\([^\)]+\))/' , $ buffer , $ matches ) ) { $ this -> log ( "Unable to perform translation on: " . $ matches [ 2 ] , Project :: MSG_WARN ) ; } $ this -> restoreEnvironment ( ) ; return $ buffer ; }
Returns the filtered stream.
The original stream is first read in fully, and then translation is performed.

@param  null $len
@throws BuildException
@return mixed the filtered stream, or -1 if the end of the resulting stream has been reached.
Returns the filtered stream . The original stream is first read in fully and then translation is performed .