From 38cfeceb3621fd8f16cee1e4deade40584e11244 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 9 Jan 2010 20:54:52 +0000 Subject: 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. git-svn-id: http://piwigo.org/svn/branches/2.0@4638 68402e56-0260-453c-a942-63ccdbb3a9ee --- tools/translation_analysis.php | 44 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'tools') diff --git a/tools/translation_analysis.php b/tools/translation_analysis.php index bf5bc4120..b1a3cb77b 100644 --- a/tools/translation_analysis.php +++ b/tools/translation_analysis.php @@ -48,37 +48,47 @@ foreach ($languages as $language) foreach ($file_list as $file) { - $missing_keys = array_diff( - array_keys($metalang[ $page['ref_compare'] ][$file]), - array_keys($metalang[ $language ][$file]) - ); - - $output = ''; - foreach ($missing_keys as $key) + if (isset($metalang[ $language ][$file])) { - $print_key = str_replace("'", '\\\'', $key); - $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]); - $output.= '$'."lang['".$print_key."'] = '".$print_value."';\n"; - } + $missing_keys = array_diff( + array_keys($metalang[ $page['ref_compare'] ][$file]), + array_keys($metalang[ $language ][$file]) + ); + + $output = ''; + foreach ($missing_keys as $key) + { + $print_key = str_replace("'", '\\\'', $key); + $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]); + $output.= '$'."lang['".$print_key."'] = '".$print_value."';\n"; + } - if ('' != $output) + if ('' != $output) + { + echo '

'.$file.'.lang.php

'; + echo ''; + } + } + else { - echo '

'.$file.'.lang.php

'; - echo ''; + echo '

'.$file.'.lang.php is missing

'; } } } function load_metalang($language, $file_list) { - global $lang; + global $lang, $user; $metalang = array(); foreach ($file_list as $file) { $lang = array(); - load_language($file.'.lang', '', array('language'=>$language)); - $metalang[$file] = $lang; + $user['language'] = $language; + if (load_language($file.'.lang', '', array('language'=>$language, 'no_fallback'=>true))) + { + $metalang[$file] = $lang; + } } return $metalang; } -- cgit v1.2.3