コード例 #1
0
ファイル: _locale.funcs.php プロジェクト: Ariflaw/b2evolution
/**
 * Get a percent of translated messages in the .PO file
 *
 * @param array File info (see result of the function locale_file_po_info() )
 * @return integer Percent
 */
function locale_file_po_percent_done($po_file_info)
{
    global $messages_pot_file_info;
    if (!isset($messages_pot_file_info)) {
        // Initialize a file info for the main language file if it doesn't yet set
        global $locales_path;
        $messages_pot_file_info = locale_file_po_info($locales_path . 'messages.pot');
    }
    $percent_done = $messages_pot_file_info['all'] > 0 ? round(($po_file_info['translated'] - $po_file_info['fuzzy'] / 2) / $messages_pot_file_info['all'] * 100) : 0;
    return $percent_done;
}
コード例 #2
0
         if (!$locale_data['enabled'] && $lkey != 'en-US') {
             // Only not enabled locale can be deleted and if it is not default locale 'en-US'
             echo action_icon(T_('Delete locale'), 'delete', '?ctrl=locales&action=delete&edit_locale=' . $lkey . ($loc_transinfo ? '&loc_transinfo=1' : '') . '&' . url_crumb('locales'));
         }
     }
     echo '</td>';
 }
 if ($loc_transinfo) {
     // Show translation info:
     // Get PO file for that locale:
     $po_file = $locales_path . $locale_data['messages'] . '/LC_MESSAGES/messages.po';
     if (!is_file($po_file)) {
         echo '<td class="lastcol center" colspan="' . (2 + (int) ($current_User->check_perm('options', 'edit') && $allow_po_extraction)) . '"><a href="?ctrl=translation&edit_locale=' . $lkey . '">' . T_('No PO file') . '</a></td>';
     } else {
         // File exists:
         $po_file_info = locale_file_po_info($po_file, true);
         // $all=$translated+$fuzzy+$untranslated;
         echo "\n\t" . '<td class="center">' . $po_file_info['all'] . '</td>';
         $percent_done = $po_file_info['percent'];
         $color = sprintf('%02x%02x00', 255 - round($percent_done * 2.55), round($percent_done * 2.55));
         echo "\n\t<td class=\"center\" style=\"background-color:#" . $color . "\"><a href=\"?ctrl=translation&edit_locale=" . $lkey . "\">" . sprintf(T_('%d%% in PO'), $percent_done) . "</a></td>";
     }
     if ($current_User->check_perm('options', 'edit') && $allow_po_extraction) {
         // Translator options:
         if (is_file($po_file)) {
             echo "\n\t" . '<td class="lastcol">[<a href="' . $pagenow . '?ctrl=locales&amp;action=extract&amp;edit_locale=' . $lkey . ($loc_transinfo ? '&amp;loc_transinfo=1' : '') . '&amp;' . url_crumb('locales') . '" title="' . T_('Extract .po file into b2evo-format') . '">' . T_('Extract') . '</a>]</td>';
         }
     }
 }
 // show message file percentage/extraction
 echo '</tr>';