Changeset 7280

Show
Ignore:
Timestamp:
11/16/08 14:59:09 (5 years ago)
Author:
p_lindheimer
Message:

fixes #3404 jump through hoops to translate strings coming from Asterisk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/dashboard/class.astinfo.php

    r7180 r7280  
    215215    } 
    216216    $astout = explode("\n",$response['data']); 
    217        
     217 
     218 
     219    // Only translate and do the preg_replace if in another language, since it is a somewhat expensive operation 
     220    // 
     221    if ($_COOKIE['lang'] == "en_US") { 
     222      $translate = false; 
     223    } else { 
     224      $translate = true; 
     225      $units = array( 
     226        '/second/', '/seconds/', 
     227        '/minute/', '/minutes/', 
     228        '/hour/', '/hours/', 
     229        '/day/', '/days/', 
     230        '/week/', '/weeks/', 
     231        '/year/', '/years/', 
     232      ); 
     233      $tunits = array( 
     234        _('second'), _('seconds'), 
     235        _('minute'), _('minutes'), 
     236        _('hour'), _('hours'), 
     237        _('day'), _('days'), 
     238        _('week'), _('weeks'), 
     239        _('year'), _('years'), 
     240      ); 
     241    } 
    218242    foreach ($astout as $line) { 
    219243      if (preg_match('/^System uptime: (.*)$/i',$line,$matches)) { 
    220244        $output["system"] = preg_replace('/,\s+(\d+ seconds?)?\s*$/', '', $matches[1]);        
     245        if ($translate) { 
     246          $output["system"] = preg_replace($units,$tunits,$output["system"]); 
     247        } 
    221248      } else if (preg_match('/^Last reload: (.*)$/i',$line,$matches)) { 
    222249        $output["reload"] = preg_replace('/,\s+(\d+ seconds?)?\s*$/', '', $matches[1]); 
     250        if ($translate) { 
     251          $output["reload"] = preg_replace($units,$tunits,$output["reload"]); 
     252        } 
    223253      } 
    224254    }