aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-01-09 23:26:45 +0000
committerplegall <plg@piwigo.org>2010-01-09 23:26:45 +0000
commitb41d62dfff079b7e7de2af9458aed304c1c20cc4 (patch)
tree2cb9b17ae8f09cf1abee476af7ab1e21e378e9f3
parent2a20b9d7a6c74a3a01c0fdc99bd4d374e9da010c (diff)
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
-rw-r--r--tools/translation_analysis.php44
1 files 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 '<h3>'.$file.'.lang.php</h3>';
echo '<textarea style="width:100%;height:150px;">'.$output.'</textarea>';
}
@@ -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