Show
Ignore:
Timestamp:
10/21/06 20:56:09 (2 years ago)
Author:
misja
Message:

Taking gettext to a new level, see message <http://lists.elgg.org/pipermail/development/2006-October/000590.html>. In a nutshell: all gettext calls are replaced by gettext, revamped gettext handling plus some additional fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/lib/uploadlib.php

    r534 r659  
    107107                        $a->name = $this->files[$name]['originalname']; 
    108108                        $a->problem = $this->files[$name]['uploadlog']; 
    109                         $msg = sprintf(gettext('Your file upload has failed because there was a problem with one of the files, %s.<br /> Here is a log of the problems:<br />%s<br />Not recovering.'), $a->name, $a->problem); 
     109                        $msg = sprintf(__gettext('Your file upload has failed because there was a problem with one of the files, %s.<br /> Here is a log of the problems:<br />%s<br />Not recovering.'), $a->name, $a->problem); 
    110110                        if (!$this->config->silent) { 
    111111                            notify($msg); 
     
    133133                        $a->oldname = $this->files[$name]['name']; 
    134134                        $a->newname = $newname; 
    135                         $this->files[$name]['uploadlog'] .= sprintf(gettext('File was renamed from %s to %s because of invalid characters.'), $a->oldname, $a->newname); 
     135                        $this->files[$name]['uploadlog'] .= sprintf(__gettext('File was renamed from %s to %s because of invalid characters.'), $a->oldname, $a->newname); 
    136136                    } 
    137137                    $this->files[$name]['name'] = $newname; 
     
    162162        } 
    163163        if ($file['size'] > $this->config->maxbytes) { 
    164             $file['uploadlog'] .= "\n". sprintf(gettext('Sorry, but that file is too big (limit is %s)'), display_size($this->config->maxbytes)); 
     164            $file['uploadlog'] .= "\n". sprintf(__gettext('Sorry, but that file is too big (limit is %s)'), display_size($this->config->maxbytes)); 
    165165            return false; 
    166166        } 
     
    215215                    chmod($destination .'/'. $this->files[$i]['name'], $CFG->filepermissions); 
    216216                    $this->files[$i]['fullpath'] = $destination.'/'.$this->files[$i]['name']; 
    217                     $this->files[$i]['uploadlog'] .= "\n".gettext('File uploaded successfully'); 
     217                    $this->files[$i]['uploadlog'] .= "\n".__gettext('File uploaded successfully'); 
    218218                    $this->files[$i]['saved'] = true; 
    219219                    $exceptions[] = $this->files[$i]['name']; 
     
    230230            $this->status = false; 
    231231            if ((empty($this->config->allownull) && !empty($this->inputname)) || (empty($this->inputname) && empty($this->config->allownullmultiple))) { 
    232                 notify(gettext('No file was found - are you sure you selected one to upload?')); 
     232                notify(__gettext('No file was found - are you sure you selected one to upload?')); 
    233233            } 
    234234            return false; 
     
    266266        } 
    267267        if ($deletedsomething) { 
    268             $msg = gettext('The old file(s) in your upload area have been deleted'); 
     268            $msg = __gettext('The old file(s) in your upload area have been deleted'); 
    269269            if (!$this->config->silent) { 
    270270                notify($msg); 
     
    297297            } 
    298298            $a->newname = $file['name']; 
    299             $file['uploadlog'] .= "\n". sprintf(gettext('File was renamed from %s to %s because there was a filename conflict.'), $a->oldname, $a->newname); 
     299            $file['uploadlog'] .= "\n". sprintf(__gettext('File was renamed from %s to %s because there was a filename conflict.'), $a->oldname, $a->newname); 
    300300        } 
    301301    } 
     
    338338        case 0: // UPLOAD_ERR_OK 
    339339            if ($file['size'] > 0) { 
    340                 $errmessage = sprintf(gettext('An unknown problem occurred while uploading the file \'%s\' (perhaps it was too large?)'), $file['name']); 
     340                $errmessage = sprintf(__gettext('An unknown problem occurred while uploading the file \'%s\' (perhaps it was too large?)'), $file['name']); 
    341341            } else { 
    342                 $errmessage = gettext('No file was found - are you sure you selected one to upload?'); /// probably a dud file name 
     342                $errmessage = __gettext('No file was found - are you sure you selected one to upload?'); /// probably a dud file name 
    343343            } 
    344344            break; 
    345345             
    346346        case 1: // UPLOAD_ERR_INI_SIZE 
    347             $errmessage = gettext('Uploaded file exceeded the maximum size limit set by the server'); 
     347            $errmessage = __gettext('Uploaded file exceeded the maximum size limit set by the server'); 
    348348            break; 
    349349             
    350350        case 2: // UPLOAD_ERR_FORM_SIZE 
    351             $errmessage = gettext('Uploaded file exceeded the maximum size limit set by the form'); 
     351            $errmessage = __gettext('Uploaded file exceeded the maximum size limit set by the form'); 
    352352            break; 
    353353             
    354354        case 3: // UPLOAD_ERR_PARTIAL 
    355             $errmessage = gettext('File was only partially uploaded'); 
     355            $errmessage = __gettext('File was only partially uploaded'); 
    356356            break; 
    357357             
    358358        case 4: // UPLOAD_ERR_NO_FILE 
    359             $errmessage = gettext('No file was found - are you sure you selected one to upload?'); 
     359            $errmessage = __gettext('No file was found - are you sure you selected one to upload?'); 
    360360            break; 
    361361             
    362362        default: 
    363             $errmessage = sprintf(gettext('An unknown problem occurred while uploading the file \'%s\' (perhaps it was too large?)'), $file['name']); 
     363            $errmessage = sprintf(__gettext('An unknown problem occurred while uploading the file \'%s\' (perhaps it was too large?)'), $file['name']); 
    364364        } 
    365365        return $errmessage; 
     
    375375                continue; 
    376376            } 
    377             $str .= '<strong>'. sprintf(gettext('Upload log for file %u'), $i+1) .' ' 
     377            $str .= '<strong>'. sprintf(__gettext('Upload log for file %u'), $i+1) .' ' 
    378378                .((!empty($this->files[$key]['originalname'])) ? '('.$this->files[$key]['originalname'].')' : '') 
    379379                .'</strong> :'. nl2br($this->files[$key]['uploadlog']) .'<br />'; 
     
    468468        if ($uselabels) { 
    469469            $lname = ((is_array($labelnames) && !empty($labelnames[$i])) ? $labelnames[$i] : 'LABEL_'.$i); 
    470             $str .= gettext('Title:').' <input type="text" size="50" name="'. $lname .'" alt="'. $lname 
     470            $str .= __gettext('Title:').' <input type="text" size="50" name="'. $lname .'" alt="'. $lname 
    471471                .'" /><br /><br />'."\n"; 
    472472        } 
     
    507507            clam_log_infected($file, $CFG->quarantinedir.'/'. $now .'-user-'. $userid .'-infected', $userid); 
    508508            if ($basiconly) { 
    509                 $notice .= "\n". gettext('The file has been moved to a quarantine directory.'); 
     509                $notice .= "\n". __gettext('The file has been moved to a quarantine directory.'); 
    510510            } 
    511511            else { 
    512                 $notice .= "\n". sprintf(gettext('The file has been moved to your specified quarantine directory, the new location is %s'), $CFG->quarantinedir.'/'. $now .'-user-'. $userid .'-infected'); 
     512                $notice .= "\n". sprintf(__gettext('The file has been moved to your specified quarantine directory, the new location is %s'), $CFG->quarantinedir.'/'. $now .'-user-'. $userid .'-infected'); 
    513513            } 
    514514        } 
    515515        else { 
    516516            if ($basiconly) { 
    517                 $notice .= "\n". gettext('The file has been deleted'); 
     517                $notice .= "\n". __gettext('The file has been deleted'); 
    518518            } 
    519519            else { 
    520                 $notice .= "\n". sprintf(gettext('Could not move the file into your specified quarantine directory, %s. You need to fix this as files are being deleted if they\'re found to be infected.'), $CFG->quarantinedir); 
     520                $notice .= "\n". sprintf(__gettext('Could not move the file into your specified quarantine directory, %s. You need to fix this as files are being deleted if they\'re found to be infected.'), $CFG->quarantinedir); 
    521521            } 
    522522        } 
     
    524524    else { 
    525525        if ($basiconly) { 
    526             $notice .= "\n". gettext('The file has been deleted'); 
     526            $notice .= "\n". __gettext('The file has been deleted'); 
    527527        } 
    528528        else { 
    529             $notice .= "\n". sprintf(gettext('Could not move the file into your specified quarantine directory, %s. You need to fix this as files are being deleted if they\'re found to be infected.'), $CFG->quarantinedir); 
     529            $notice .= "\n". sprintf(__gettext('Could not move the file into your specified quarantine directory, %s. You need to fix this as files are being deleted if they\'re found to be infected.'), $CFG->quarantinedir); 
    530530        } 
    531531    } 
     
    533533        if (unlink($file)) { 
    534534            clam_log_infected($file, '', $userid); 
    535             $notice .= "\n". gettext('The file has been deleted'); 
     535            $notice .= "\n". __gettext('The file has been deleted'); 
    536536        } 
    537537        else { 
    538538            if ($basiconly) { 
    539539                // still tell the user the file has been deleted. this is only for admins. 
    540                 $notice .= "\n". gettext('The file has been deleted'); 
     540                $notice .= "\n". __gettext('The file has been deleted'); 
    541541            } 
    542542            else { 
    543                 $notice .= "\n". gettext('The file could not be deleted'); 
     543                $notice .= "\n". __gettext('The file could not be deleted'); 
    544544            } 
    545545        } 
     
    557557 */ 
    558558function clam_replace_infected_file($file) { 
    559     $newcontents = gettext('This file that has been uploaded was found to contain a virus and has been moved or delted and the user notified.'); 
     559    $newcontents = __gettext('This file that has been uploaded was found to contain a virus and has been moved or delted and the user notified.'); 
    560560    if (!$f = fopen($file, 'w')) { 
    561561        return false; 
     
    593593    if (!$CFG->pathtoclam || !file_exists($CFG->pathtoclam) || !is_executable($CFG->pathtoclam)) { 
    594594        $newreturn = 1; 
    595         $notice = sprintf(gettext('Elgg is configured to run clam on file upload, but the path supplied to Clam AV, %s,  is invalid.'), $CFG->pathtoclam); 
     595        $notice = sprintf(__gettext('Elgg is configured to run clam on file upload, but the path supplied to Clam AV, %s,  is invalid.'), $CFG->pathtoclam); 
    596596        if ($CFG->clamfailureonupload == 'actlikevirus') { 
    597             $notice .= "\n". gettext('In addition, Elgg is configured so that if clam fails to run, files are treated like viruses.  This essentially means that no student can upload a file successfully until you fix this.'); 
     597            $notice .= "\n". __gettext('In addition, Elgg is configured so that if clam fails to run, files are treated like viruses.  This essentially means that no student can upload a file successfully until you fix this.'); 
    598598            $notice .= "\n". clam_handle_infected_file($fullpath); 
    599599            $newreturn = false;  
     
    601601        clam_mail_admins($notice); 
    602602        if ($appendlog) { 
    603             $file['uploadlog'] .= "\n". gettext('Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.'); 
     603            $file['uploadlog'] .= "\n". __gettext('Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.'); 
    604604            $file['clam'] = 1; 
    605605        } 
     
    619619    case 1:  // bad wicked evil, we have a virus. 
    620620        $info->user = $USER->name; 
    621         $notice = sprintf(gettext('Attention administrator! Clam AV has found a virus in a file uploaded by %s. Here is the output of clamscan:'), $info->user); 
     621        $notice = sprintf(__gettext('Attention administrator! Clam AV has found a virus in a file uploaded by %s. Here is the output of clamscan:'), $info->user); 
    622622        $notice .= "\n\n". implode("\n", $output); 
    623623        $notice .= "\n\n". clam_handle_infected_file($fullpath);  
     
    625625        if ($appendlog) { 
    626626            $info->filename = $file['originalname']; 
    627             $file['uploadlog'] .= "\n". sprintf(gettext('The file you have uploaded, %s, has been scanned by a virus checker and found to be infected! Your file upload was NOT successful.'), $info->filename); 
     627            $file['uploadlog'] .= "\n". sprintf(__gettext('The file you have uploaded, %s, has been scanned by a virus checker and found to be infected! Your file upload was NOT successful.'), $info->filename); 
    628628            $file['virus'] = 1; 
    629629        } 
     
    631631    default:  
    632632        // error - clam failed to run or something went wrong 
    633         $notice .= sprintf(gettext('Clam AV has failed to run.  The return error message was %s. Here is the output from Clam:'), get_clam_error_code($return)); 
     633        $notice .= sprintf(__gettext('Clam AV has failed to run.  The return error message was %s. Here is the output from Clam:'), get_clam_error_code($return)); 
    634634        $notice .= "\n\n". implode("\n", $output); 
    635635        $newreturn = true; 
     
    640640        clam_mail_admins($notice); 
    641641        if ($appendlog) { 
    642             $file['uploadlog'] .= "\n". gettext('Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.'); 
     642            $file['uploadlog'] .= "\n". __gettext('Your administrator has enabled virus checking for file uploads but has misconfigured something.<br />Your file upload was NOT successful. Your administrator has been emailed to notify them so they can fix it.<br />Maybe try uploading this file later.'); 
    643643            $file['clam'] = 1; 
    644644        } 
     
    656656    global $CFG; 
    657657         
    658     $subject = sprintf(gettext('%s :: Clam AV notification'), $CFG->sitename); 
     658    $subject = sprintf(__gettext('%s :: Clam AV notification'), $CFG->sitename); 
    659659    $user = new StdClass; 
    660660    $user->email = $CFG->sysadminemail; 
    661     $user->name = $CFG->sitename.' '.gettext('Administrator'); 
     661    $user->name = $CFG->sitename.' '.__gettext('Administrator'); 
    662662    email_to_user($user,$user,$subject,$notice); 
    663663    /* 
     
    700700    if ($returncodes[$returncode]) 
    701701       return $returncodes[$returncode]; 
    702     return gettext('There was an unknown error with clam.'); 
     702    return __gettext('There was an unknown error with clam.'); 
    703703 
    704704}