Changeset 4644 for branches/2.0


Ignore:
Timestamp:
Jan 10, 2010, 12:26:45 AM (14 years ago)
Author:
plg
Message:

feature 1374 related: improve the problems on translations. Ability to detect
if the key was duplicated from the reference language BUT not really
translated yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/tools/translation_analysis.php

    r4638 r4644  
    5656        );
    5757
    58       $output = '';
     58      $output_missing = '';
    5959      foreach ($missing_keys as $key)
    6060      {
    61         $print_key = str_replace("'", '\\\'', $key);
    62         $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]);
    63         $output.= '$'."lang['".$print_key."'] = '".$print_value."';\n";
     61        $output_missing.= get_line_to_translate($file, $key);
    6462      }
    6563
    66       if ('' != $output)
     64      // strings not "really" translated?
     65      $output_duplicated = '';
     66      foreach (array_keys($metalang[$language][$file]) as $key)
    6767      {
     68        $exceptions = array('Level 0');
     69        if (in_array($key, $exceptions))
     70        {
     71          continue;
     72        }
     73       
     74        $local_value = $metalang[$language][$file][$key];
     75        $ref_value = $metalang[ $page['ref_default_values'] ][$file][$key];
     76        if ($local_value == $ref_value)
     77        {
     78          $output_duplicated.= get_line_to_translate($file, $key);
     79        }
     80      }
     81
     82      if ('' != $output_missing or '' != $output_duplicated)
     83      {
     84        $output = '';
     85        if ('' != $output_missing)
     86        {
     87          $output.= "// missing translations\n".$output_missing;
     88        }
     89        if ('' != $output_duplicated)
     90        {
     91          $output.= "\n// untranslated yet\n".$output_duplicated;
     92        }
    6893        echo '<h3>'.$file.'.lang.php</h3>';
    6994        echo '<textarea style="width:100%;height:150px;">'.$output.'</textarea>';
     
    93118  return $metalang;
    94119}
     120
     121function get_line_to_translate($file, $key)
     122{
     123  global $metalang, $page;
     124 
     125  $print_key = str_replace("'", '\\\'', $key);
     126  $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]);
     127  return '$'."lang['".$print_key."'] = '".$print_value."';\n";
     128}
    95129?>
Note: See TracChangeset for help on using the changeset viewer.