From b41d62dfff079b7e7de2af9458aed304c1c20cc4 Mon Sep 17 00:00:00 2001 From: plegall Date: Sat, 9 Jan 2010 23:26:45 +0000 Subject: [PATCH] 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. git-svn-id: http://piwigo.org/svn/branches/2.0@4644 68402e56-0260-453c-a942-63ccdbb3a9ee --- tools/translation_analysis.php | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/tools/translation_analysis.php b/tools/translation_analysis.php index b1a3cb77b..d5ae444ca 100644 --- a/tools/translation_analysis.php +++ b/tools/translation_analysis.php @@ -55,16 +55,41 @@ foreach ($languages as $language) array_keys($metalang[ $language ][$file]) ); - $output = ''; + $output_missing = ''; 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"; + $output_missing.= get_line_to_translate($file, $key); } - if ('' != $output) + // strings not "really" translated? + $output_duplicated = ''; + foreach (array_keys($metalang[$language][$file]) as $key) { + $exceptions = array('Level 0'); + if (in_array($key, $exceptions)) + { + continue; + } + + $local_value = $metalang[$language][$file][$key]; + $ref_value = $metalang[ $page['ref_default_values'] ][$file][$key]; + if ($local_value == $ref_value) + { + $output_duplicated.= get_line_to_translate($file, $key); + } + } + + if ('' != $output_missing or '' != $output_duplicated) + { + $output = ''; + if ('' != $output_missing) + { + $output.= "// missing translations\n".$output_missing; + } + if ('' != $output_duplicated) + { + $output.= "\n// untranslated yet\n".$output_duplicated; + } echo '

'.$file.'.lang.php

'; echo ''; } @@ -92,4 +117,13 @@ function load_metalang($language, $file_list) } return $metalang; } + +function get_line_to_translate($file, $key) +{ + global $metalang, $page; + + $print_key = str_replace("'", '\\\'', $key); + $print_value = str_replace("'", '\\\'', $metalang[ $page['ref_default_values'] ][$file][$key]); + return '$'."lang['".$print_key."'] = '".$print_value."';\n"; +} ?> \ No newline at end of file