Changeset 270 for trunk/patTemplate

Show
Ignore:
Timestamp:
08/20/04 10:33:44 (4 years ago)
Author:
schst
Message:

fixed bugs in Translate function, fixed bug 60

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/patTemplate/Function/Translate.php

    r258 r270  
    220220         * get the 'gettext' source file 
    221221         */ 
    222         $this->_sentences[$input]   =   @parse_ini_file( $this->_config['sentenceFile'] ); 
     222        $this->_sentences[$input]   =   @parse_ini_file( $this->_config[$input]['sentenceFile'] ); 
    223223        if( !is_array( $this->_sentences[$input] ) ) 
    224224            $this->_sentences[$input] = array(); 
     225        else 
     226            $this->_sentences[$input] = array_map( array( $this, '_unescape' ), $this->_sentences[$input] ); 
     227         
    225228         
    226229        return true; 
     
    244247            if( is_array( $tmp ) ) 
    245248            { 
     249                $tmp = array_map( array( $this, '_unescape' ), $tmp ); 
    246250                $this->_translation[$input] =   $tmp; 
    247251                return true; 
     
    250254        return false; 
    251255    } 
     256 
     257   /** 
     258    * unsecape the text that has been read from the translation file 
     259    * 
     260    * @access   private 
     261    * @param    string 
     262    * @return   string 
     263    */ 
     264    function _unescape( $text ) 
     265    { 
     266        return str_replace( '"', '"', $text ); 
     267    } 
    252268     
    253269   /** 
     
    255271    * 
    256272    * @access   private 
    257      
    258273    * @param    string  unique key 
    259274    * @param    string  sentence to translate 
     
    266281        if( !$fp ) 
    267282            return false; 
    268         fputs( $fp, sprintf( '%s = "%s"'."\n", $key, addslashes( $content ) ) ); 
     283        fputs( $fp, sprintf( '%s = "%s"'."\n", $key, str_replace( '"', '"', $content ) ) ); 
    269284        flock( $fp, LOCK_UN ); 
    270285        fclose( $fp );