Ignore:
Timestamp:
Jun 24, 2013, 1:23:50 AM (11 years ago)
Author:
mistic100
Message:

display unused strings as useless

Location:
extensions/plugin_lang_analysis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/plugin_lang_analysis/admin.php

    r23473 r23488  
    205205  unset($string_data);
    206206 
     207  // unused strings
     208  $unused = array();
     209  foreach ($language_files as $name => $path)
     210  {
     211    $unused = array_merge($unused, array_diff_key($lang_plugin[ $name ], $strings));
     212  }
     213 
     214  foreach ($unused as $string => $translation)
     215  {
     216    $string_data = array(
     217      'files' => array(),
     218      'in_common' => array_key_exists($string, $lang_common),
     219      'in_admin' => array_key_exists($string, $lang_admin),
     220      'in_plugin' => array(),
     221      'stat' => 'useless',
     222      'is_admin' => false,
     223      'warning' => array(l10n('This string is not used anywhere in the plugin')),
     224      );
     225     
     226    foreach ($language_files as $name => $path)
     227    {
     228      if (array_key_exists($string, $lang_plugin[$name])) $string_data['in_plugin'][] = $name;
     229    }
     230   
     231    $strings[ $string ] = $string_data;
     232  }
     233 
    207234  uksort($strings, 'strnatcasecmp'); // natural sort
    208235  $counts['total'] = array_sum($counts);
  • extensions/plugin_lang_analysis/main.inc.php

    r23473 r23488  
    2121define('PLA_PATH' , PHPWG_PLUGINS_PATH . PLA_ID . '/');
    2222define('PLA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . PLA_ID);
    23 define('PLA_DATA', $conf['data_location'] . PLA_ID . '/');
     23define('PLA_DATA',  $conf['data_location'] . PLA_ID . '/');
    2424
    2525add_event_handler('loc_begin_admin', 'pla_begin_admin');
  • extensions/plugin_lang_analysis/template/analysis.tpl

    r23472 r23488  
    8888      <td>
    8989        {$string|htmlspecialchars}
    90         {if isset($data.warnings)}<span class="iconpla-attention-circled tiptip" title="{'<br>'|@implode:$data.warning}"></span>{/if}
     90        {if isset($data.warnings)}<span class="iconpla-attention-circled tiptip" title="{'<br>'|@implode:$data.warnings}"></span>{/if}
    9191      </td>
    9292      {if $data.is_admin}<td class="text-admin">{'Admin'|@translate}</td>
     
    111111        <td></td>
    112112      </tr>
     113    {foreachelse}
     114      <tr class="file string-{$data.stat} useless">
     115        <td></td>
     116        <td><i>{'Unused'|@translate}</i></td>
     117        {'<td></td>'|str_repeat:(3+$PLA_LANG_FILES|@count)}
     118      </tr>
    113119    {/foreach} {* <!-- end file --> *}
    114120  {/foreach} {* <!-- end string --> *}
     
    119125      <th></th>
    120126      <th>{'%d strings : %d missing and %d useless.'|@translate|sprintf:$PLA_COUNTS.total:$PLA_COUNTS.missing:$PLA_COUNTS.useless}</th>
    121       <th></th>
    122     {foreach from=$PLA_LANG_FILES item=path key=lang_file}
    123       <th></th>
    124     {/foreach}
    125       <th></th>
    126       <th></th>
     127      {'<th></th>'|str_repeat:(3+$PLA_LANG_FILES|@count)}
    127128    </tr>
    128129  </tfoot>
Note: See TracChangeset for help on using the changeset viewer.