Changeset 4638 for branches/2.0


Ignore:
Timestamp:
Jan 9, 2010, 9:54:52 PM (14 years ago)
Author:
plg
Message:

feature 1374 related: force to load exactly the language requested and not any
fallback language. If the language file is missing, we tell it explicitely.

File:
1 edited

Legend:

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

    r4637 r4638  
    4949  foreach ($file_list as $file)
    5050  {
    51     $missing_keys = array_diff(
    52       array_keys($metalang[ $page['ref_compare'] ][$file]),
    53       array_keys($metalang[ $language ][$file])
    54       );
     51    if (isset($metalang[ $language ][$file]))
     52    {
     53      $missing_keys = array_diff(
     54        array_keys($metalang[ $page['ref_compare'] ][$file]),
     55        array_keys($metalang[ $language ][$file])
     56        );
    5557
    56     $output = '';
    57     foreach ($missing_keys as $key)
     58      $output = '';
     59      foreach ($missing_keys as $key)
     60      {
     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";
     64      }
     65
     66      if ('' != $output)
     67      {
     68        echo '<h3>'.$file.'.lang.php</h3>';
     69        echo '<textarea style="width:100%;height:150px;">'.$output.'</textarea>';
     70      }
     71    }
     72    else
    5873    {
    59       $print_key = str_replace("'", '\\\'', $key);
    60       $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]);
    61       $output.= '$'."lang['".$print_key."'] = '".$print_value."';\n";
    62     }
    63 
    64     if ('' != $output)
    65     {
    66       echo '<h3>'.$file.'.lang.php</h3>';
    67       echo '<textarea style="width:100%;height:150px;">'.$output.'</textarea>';
     74      echo '<h3>'.$file.'.lang.php is missing</h3>';
    6875    }
    6976  }
     
    7279function load_metalang($language, $file_list)
    7380{
    74   global $lang;
     81  global $lang, $user;
    7582 
    7683  $metalang = array();
     
    7885  {
    7986    $lang = array();
    80     load_language($file.'.lang', '', array('language'=>$language));
    81     $metalang[$file] = $lang;
     87    $user['language'] = $language;
     88    if (load_language($file.'.lang', '', array('language'=>$language, 'no_fallback'=>true)))
     89    {
     90      $metalang[$file] = $lang;
     91    }
    8292  }
    8393  return $metalang;
Note: See TracChangeset for help on using the changeset viewer.