Ignore:
Timestamp:
10/08/09 18:30:44 (15 years ago)
Author:
rodsouza
Message:

Ticket #622 - Utilizar XML para internacionalização.

Location:
trunk/expressoMail1_2/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/inc/class.functions.inc.php

    r1384 r1503  
    9999                        return $response; 
    100100                } 
    101                  
    102                 function getLang($key){ 
    103                         if ($_SESSION['phpgw_info']['expressomail']['lang'][$key]) 
    104                         return $_SESSION['phpgw_info']['expressomail']['lang'][$key];                    
     101 
     102                function getLang( $key ) 
     103                { 
     104                        static $language = NULL; 
     105 
     106                        if ( ! $language ) 
     107                        { 
     108                                $_SESSION[ 'debug' ][ 'init_t' ] = time( ); 
     109                                $_SESSION[ 'debug' ][ 'init_m' ] = microtime( ); 
     110 
     111                                $xml = new DOMDocument; 
     112                                $xml -> preserveWhiteSpace = false; 
     113                                $xml -> load( dirname( __FILE__ ) 
     114                                        . '/../setup/phpgw_' 
     115                                        . $_SESSION['phpgw_info']['expressomail']['user']['preferences']['common']['lang'] 
     116                                        . '.xml' 
     117                                ); 
     118 
     119                                $xpath = new DOMXPath( $xml ); 
     120 
     121                                $_key = 'key'; 
     122                                $_lang = 'translation'; 
     123 
     124                                $language = array( ); 
     125                                foreach( $xml -> documentElement -> childNodes as $entry ) 
     126                                        $language[ $xpath->query( $_key, $entry ) -> item( 0 ) -> nodeValue ] = $xpath->query( $_lang, $entry ) -> item( 0 ) -> nodeValue; 
     127 
     128                                $_SESSION[ 'debug' ][ 'end_t' ] = time( ); 
     129                                $_SESSION[ 'debug' ][ 'end_m' ] = microtime( ); 
     130                        } 
     131 
     132                        if ( array_key_exists( $key, $language ) ) 
     133                                return $language[ $key ]; 
    105134                        else 
    106                                 return ($key . '*'); 
     135                                return ( $key . '*' ); 
    107136                } 
    108137 
  • trunk/expressoMail1_2/inc/load_lang.php

    r1121 r1503  
    2121        foreach($_SESSION['phpgw_info']['expressomail']['lang'] as $key => $value) 
    2222                $script .= "array_lang['".str_replace("'","\'",strtolower($key))."'] = '".str_replace("'","\'",$value)."';\n"; 
    23         echo "<script type='text/javascript'>$script</script>"; 
     23        //echo "<script type='text/javascript'>$script</script>"; 
    2424?> 
Note: See TracChangeset for help on using the changeset viewer.