Ticket #977: result.inc.diff

File result.inc.diff, 12.9 KB (added by Christian Beer, 14 years ago)
  • inc/result.inc

     
    2222function app_version_string($id) {
    2323    global $apps, $app_versions;
    2424    if ($id == 0) return "";
    25     if ($id == -1) return "Anonymous platform";
     25    if ($id == -1) return tra("Anonymous platform");
    2626    if (array_key_exists($id, $app_versions)) {
    2727        $av = $app_versions[$id];
    2828        $app = $apps[$av->appid];
    2929    } else {
    3030        $av = BoincAppVersion::lookup("id=$id");
    3131        if (!$av) {
    32             return "Not in DB";
     32            return tra("Not in DB");
    3333        }
    3434        $app_versions[$id] = $av;
    3535        $app = BoincApp::lookup_id($av->appid);
     
    6767        switch ($result->validate_state) {
    6868        case 0:
    6969        case 4:
    70             return "pending";
     70            return tra("pending");
    7171        }
    7272        return $string_to_show;
    7373    default:
     
    8989define("NSTATES", 6);
    9090
    9191$state_name = array(
    92     "All",
    93     "In progress",
    94     "Pending",
    95     "Valid",
    96     "Invalid",
    97     "Error",
     92    tra("All"),
     93    tra("In progress"),
     94    tra("Pending"),
     95    tra("Valid"),
     96    tra("Invalid"),
     97    tra("Error"),
    9898);
    9999
    100100$state_clause = array(
     
    108108
    109109function state_string($result) {
    110110    switch ($result->server_state) {
    111     case 1: return "Inactive";
    112     case 2: return "Unsent";
    113     case 4: return "In progress";
     111    case 1: return tra("Inactive");
     112    case 2: return tra("Unsent");
     113    case 4: return tra("In progress");
    114114    case 5:
    115115        switch ($result->outcome) {
    116116        case 1:
    117117            switch ($result->validate_state) {
    118             case 0: return "Completed, waiting for validation";
    119             case 1: return "Completed and validated";
    120             case 2: return "Completed, marked as invalid";
    121             case 3: return "Completed, can't validate";
    122             case 4: return "Completed, validation inconclusive";
    123             case 5: return "Completed, too late to validate";
     118            case 0: return tra("Completed, waiting for validation");
     119            case 1: return tra("Completed and validated");
     120            case 2: return tra("Completed, marked as invalid");
     121            case 3: return tra("Completed, can't validate");
     122            case 4: return tra("Completed, validation inconclusive");
     123            case 5: return tra("Completed, too late to validate");
    124124            }
    125             return "Completed";
    126         case 2: return "Couldn't send";
     125            return tra("Completed");
     126        case 2: return tra("Couldn't send");
    127127        case 3:
    128128            if ($result->exit_status == -221) {
    129                 return "Cancelled by server";
     129                return tra("Cancelled by server");
    130130            }
    131131            switch($result->client_state) {
    132             case 1: return "Error while downloading";
    133             case 2: return "Error while computing";
    134             case 3: return "Error while computing";
    135             case 4: return "Error while uploading";
    136             case 6: return "Aborted by user";
     132            case 1: return tra("Error while downloading");
     133            case 2:
     134            case 3: return tra("Error while computing");
     135            case 4: return tra("Error while uploading");
     136            case 6: return tra("Aborted by user");
    137137            }
    138             return "Error";
    139         case 4: return "Timed out - no response";
    140         case 5: return "Didn't need";
    141         case 6: return "Validate error";
    142         case 7: return "Client detached";
     138            return tra("Error");
     139        case 4: return tra("Timed out - no response");
     140        case 5: return tra("Didn't need");
     141        case 6: return tra("Validate error");
     142        case 7: return tra("Client detached");
    143143        }
    144144    }
    145     return "Unknown";
     145    return tra("Unknown");
    146146}
    147147
    148148function result_server_state_string($result) {
    149149    switch($result->server_state) {
    150     case 1: return "Inactive";
    151     case 2: return "Unsent";
    152     case 4: return "In progress";
    153     case 5: return "Over";
     150    case 1: return tra("Inactive");
     151    case 2: return tra("Unsent");
     152    case 4: return tra("In progress");
     153    case 5: return tra("Over");
    154154    }
    155     return "Unknown";
     155    return tra("Unknown");
    156156}
    157157
    158158function result_outcome_string($result) {
    159159    switch($result->outcome) {
    160160    case 0: return "---";
    161     case 1: return "Success";
    162     case 2: return "Couldn't send";
     161    case 1: return tra("Success");
     162    case 2: return tra("Couldn't send");
    163163    case 3:
    164164        if ($result->exit_status <> -221) {
    165             return "Client error";
     165            return tra("Client error");
    166166        }
    167         return "Redundant result";
    168     case 4: return "No reply";
    169     case 5: return "Didn't need";
    170     case 6: return "Validate error";
    171     case 7: return "Client detached";
     167        return tra("Redundant result");
     168    case 4: return tra("No reply");
     169    case 5: return tra("Didn't need");
     170    case 6: return tra("Validate error");
     171    case 7: return tra("Client detached");
    172172    }
    173     return "Unknown";
     173    return tra("Unknown");
    174174}
    175175
    176176function result_client_state_string($result) {
    177177    switch($result->client_state) {
    178     case 0: return "New";
    179     case 1: return "Downloading";
    180     case 2: return "Computing";
    181     case 3: return "Compute error";
    182     case 4: return "Uploading";
    183     case 5: return "Done";
     178    case 0: return tra("New");
     179    case 1: return tra("Downloading");
     180    case 2: return tra("Computing");
     181    case 3: return tra("Compute error");
     182    case 4: return tra("Uploading");
     183    case 5: return tra("Done");
    184184    case 6:
    185185        if ($result->exit_status == -221) {
    186             return "Cancelled by server";
     186            return tra("Cancelled by server");
    187187        }
    188         return "Aborted by user";
     188        return tra("Aborted by user");
    189189    }
    190190}
    191191
    192192function validate_state_str($result) {
    193193    switch($result->validate_state) {
    194     case 0: return "Initial";
    195     case 1: return "Valid";
     194    case 0: return tra("Initial");
     195    case 1: return tra("Valid");
    196196    case 2:
    197197        if ($result->exit_status <> -221) {
    198             return "Invalid";
     198            return tra("Invalid");
    199199        }
    200         return "Not necessary";
    201     case 3: return "Workunit error - check skipped";
    202     case 4: return "Checked, but no consensus yet";
    203     case 5: return "Task was reported too late to validate";
     200        return tra("Not necessary");
     201    case 3: return tra("Workunit error - check skipped");
     202    case 4: return tra("Checked, but no consensus yet");
     203    case 5: return tra("Task was reported too late to validate");
    204204    }
    205     return "Unknown";
     205    return tra("Unknown");
    206206}
    207207
    208208function wu_error_mask_str($s) {
    209209    $x = "";
    210210    if ($s & 1) {
    211         $x = $x."Couldn't send result ";
     211        $x = $x." ".tra("Couldn't send result");
    212212        $s -= 1;
    213213    }
    214214    if ($s & 2) {
    215         $x = $x."Too many error results ";
     215        $x = $x." ".tra("Too many errors (may have bug)");
    216216        $s -= 2;
    217217    }
    218218    if ($s & 4) {
    219         $x = $x."Too many success results ";
     219        $x = $x." ".tra("Too many results (may be nondeterministic)");
    220220        $s -= 4;
    221221    }
    222222    if ($s & 8) {
    223         $x = $x."Too many total results ";
     223        $x = $x." ".tra("Too many total results");
    224224        $s -= 8;
    225225    }
    226226    if ($s & 16) {
    227         $x = $x."Cancelled ";
     227        $x = $x." ".tra("WU cancelled");
    228228        $s -= 16;
    229229    }
    230230    if ($s) {
    231         $x = $x."Unrecognized Error: $s ";
     231        $x = $x." ".tra("Unrecognized Error: %1", $s);
    232232    }
    233     if (!strlen($x)) {
    234         $x="<br>";
     233    if (strlen($x)) {
     234        $x="<font color=\"#ff3333\">".$x."</font>";
     235    } else {
     236        $x="";
    235237    }
    236238    return $x;
    237239}
     
    252254            $i2 = clone $info;
    253255            $i2->show_names = 0;
    254256            $url = result_page_url($i2);
    255             echo "<th>Task name<br><span class=\"smalltext\">click for details<br><a href=$url>Show IDs</a></span></th>\n";
     257            echo "<th>".tra("Task name")."<br><span class=\"smalltext\">".tra("click for details")."<br><a href=$url>".tra("Show IDs")."</a></span></th>\n";
    256258        } else {
    257259            $i2 = clone $info;
    258260            $i2->show_names = 1;
    259261            $url = result_page_url($i2);
    260             echo "<th>Task ID<br><span class=\"smalltext\">click for details<br><a href=$url>Show names</a></span></th>\n";
     262            echo "<th>Task ID<br><span class=\"smalltext\">".tra("click for details")."<br><a href=$url>".tra("Show names")."</a></span></th>\n";
    261263        }
    262264    } else {
    263         echo "<th>Task ID<br><span class=\"smalltext\">click for details</span></th>\n";
     265        echo "<th>".tra("Task ID")."<br><span class=\"smalltext\">".tra("click for details")."</span></th>\n";
    264266    }
    265267    if ($show_wu_link) {
    266         echo "<th>Work unit ID<br><span class=\"smalltext\">click for details</span></th>\n";
     268        echo "<th>".tra("Work unit ID")."<br><span class=\"smalltext\">".tra("click for details")."</span></th>\n";
    267269    }
    268270    if ($show_host_link) {
    269         echo "<th>Computer</th>\n";
     271        echo "<th>".tra("Computer")."</th>\n";
    270272    }
    271273    echo "
    272         <th>Sent</th>
    273         <th>Time reported
    274             <br>or deadline
    275             <br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_time\">explain</a></span>
     274        <th>".tra("Sent")."</th>
     275        <th>".tra("Time reported<br />or deadline")."
     276            <br><span class=\"smalltext\"><a href=\"explain_state.php?field=result_time\">".tra("explain")."</a></span>
    276277        </th>
    277         <th>Status</th>
    278         <th>Run time<br>(sec)</th>
    279         <th>CPU time<br>(sec)</th>
    280         <th>Claimed credit</th>
    281         <th>Granted credit</th>
    282         <th>Application</th>
     278        <th>".tra("Status")."</th>
     279        <th>".tra("Run time<br />(sec)")."</th>
     280        <th>".tra("CPU time<br />(sec)")."</th>
     281        <th>".tra("Claimed credit")."</th>
     282        <th>".tra("Granted credit")."</th>
     283        <th>".tra("Application")."</th>
    283284        </tr>
    284285    ";
    285286}
     
    371372
    372373function show_result($result) {
    373374    start_table();
    374     row2("Name", $result->name);
    375     row2("Workunit", "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
    376     row2("Created", time_str($result->create_time));
    377     row2("Sent", time_str($result->sent_time));
    378     row2("Received", time_str($result->received_time));
    379     row2("Server state", result_server_state_string($result));
    380     row2("Outcome", result_outcome_string($result));
    381     row2("Client state", result_client_state_string($result));
    382     row2("Exit status", exit_status_string($result));
    383     row2("Computer ID", host_link($result->hostid));
    384     row2("Report deadline", time_str($result->report_deadline));
    385     row2("Run time", $result->elapsed_time);
    386     row2("CPU time", $result->cpu_time);
    387     row2("stderr out", "<pre>".htmlspecialchars($result->stderr_out)."</pre>");
    388     row2("Validate state", validate_state_str($result));
    389     row2("Claimed credit", $result->claimed_credit);
    390     row2("Granted credit", $result->granted_credit);
    391     row2("application version", app_version_string($result->app_version_id));
     375    row2(tra("Name"), $result->name);
     376    row2(tra("Workunit"), "<a href=\"workunit.php?wuid=$result->workunitid\">$result->workunitid</a>");
     377    row2(tra("Created"), time_str($result->create_time));
     378    row2(tra("Sent"), time_str($result->sent_time));
     379    row2(tra("Received"), time_str($result->received_time));
     380    row2(tra("Server state"), result_server_state_string($result));
     381    row2(tra("Outcome"), result_outcome_string($result));
     382    row2(tra("Client state"), result_client_state_string($result));
     383    row2(tra("Exit status"), exit_status_string($result));
     384    row2(tra("Computer ID"), host_link($result->hostid));
     385    row2(tra("Report deadline"), time_str($result->report_deadline));
     386    row2(tra("Run time"), $result->elapsed_time);
     387    row2(tra("CPU time"), $result->cpu_time);
     388    row2(tra("stderr out"), "<pre>".htmlspecialchars($result->stderr_out)."</pre>");
     389    row2(tra("Validate state"), validate_state_str($result));
     390    row2(tra("Claimed credit"), $result->claimed_credit);
     391    row2(tra("Granted credit"), $result->granted_credit);
     392    row2(tra("application version"), app_version_string($result->app_version_id));
    392393    end_table();
    393394}
    394395
     
    402403        $i2 = clone $info;
    403404        $i2->offset = $info->offset - $info->results_per_page;
    404405        $url = result_page_url($i2);
    405         echo "<a href=$url>Previous ".$info->results_per_page."</a>";
     406        echo "<a href=$url>".tra("Previous")." ".$info->results_per_page."</a>";
    406407    }
    407408    if ($show_prev && $show_next) {
    408409        echo "&nbsp;|&nbsp;";
     
    411412        $i2 = clone $info;
    412413        $i2->offset = $info->offset + $info->results_per_page;
    413414        $url = result_page_url($i2);
    414         echo "<a href=$url>Next ".$info->results_per_page."</a>";
     415        echo "<a href=$url>".tra("Next")." ".$info->results_per_page."</a>";
    415416    }
    416417    echo "<br>Show: ";
    417418    for ($i=0; $i<NSTATES; $i++) {