From 42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c Mon Sep 17 00:00:00 2001 From: Filip Komar Date: Fri, 7 Mar 2014 22:01:48 +0000 Subject: first steps as a preparation of l10n report (only diff.php for now - 3 exceptions) to gettext system --- langs/diff.php | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'langs/diff.php') diff --git a/langs/diff.php b/langs/diff.php index c231b9131..bc6e0ab5a 100644 --- a/langs/diff.php +++ b/langs/diff.php @@ -6,8 +6,6 @@ include 'lib.php'; -define('APP_ROOT', realpath(__DIR__ . '/..')); - $source_file = isset($_GET['s']) ? strip_tags(trim($_GET['s'])) : null; $target_lang = isset($_GET['l']) ? strip_tags(trim($_GET['l'])) : null; @@ -21,43 +19,55 @@ if (!file_exists($source_file)) { die('no source'); } -$target_file = _lang_file_switch($source_file, $target_lang); +if (strrpos($source_file, '.pot')) { + $gettext = true; + $resource = _extract_resource($source_file); + $target_file = _po_file_switch($source_file, $target_lang); +} else { + $gettext = false; + $resource = _extract_resource($source_file, '.en.lang'); + $target_file = _lang_file_switch($source_file, $target_lang); +} if (!file_exists($target_file)) { die('no target'); } -if($source_file =='en/about/constitution.en.lang') { +if($resource =='about/constitution') { $constitution = true; } else { $constitution = false; } -if($source_file =='en/about/license.en.lang') { +if($resource =='about/license') { $license = true; } else { $license = false; } if ($source_file == '../_nav/langs/en.lang') { - $file = substr(_lang_file_switch($source_file, $target_lang), 14); + $file = substr($target_file, 14); $note = ' NOTE: THIS IS TRANSLATION OF NAVIGATION SO LOCATION FOR COMMIT IS DIFFERENT!'; $commit = 'web/www/trunk/_nav/langs/' . $file . ' and for now to the web/nav/langs/' . $file . ' too'; } else { - $file = _lang_file_switch($source_file, $target_lang); + $file = $target_file; $note = ''; $commit = 'web/www/trunk/langs/' . $file . ''; } -$source_file = realpath($source_file); -$target_file = realpath($target_file); +$source_file_path = realpath($source_file); +$target_file_path = realpath($target_file); -if (false === strstr($source_file, '/langs/') || - false == strstr($target_file, '/langs/')) { +if (false === strstr($source_file_path, '/langs/') || + false == strstr($target_file_path, '/langs/')) { die('no sorry'); } -$diff = _lang_diff($source_file, $target_file); +if ($gettext) { + $diff = _po_diff($target_lang, $resource); +} else { + $diff = _lang_diff($source_file_path, $target_file_path); +} $issues = array( 'missing' => 'missing strings', @@ -68,15 +78,15 @@ $issues = array( $s = '« back to the report page for ' . $langs[$target_lang] . ''; $s .= sprintf('

Differences between %s source and %s target

', - substr($source_file, strpos($source_file, '/langs/')+7), $target_lang); + $source_file, $target_lang); if($constitution) { $s .= '

Please translate constitution fully into ' . $langs[$target_lang] . ' first

'; $s .= '

You can find it in svn. '; - $constitution_results = aproximate_number_of_untranslated_constitution_lines(APP_ROOT, 'en'); + $constitution_results = aproximate_number_of_untranslated_constitution_lines(G_APP_ROOT, 'en'); $unique_lines_in_eng_constitution = $constitution_results['unique_lines_in_constitution']; - $lang_constitution_results = aproximate_number_of_untranslated_constitution_lines(APP_ROOT, $target_lang, $unique_lines_in_eng_constitution); + $lang_constitution_results = aproximate_number_of_untranslated_constitution_lines(G_APP_ROOT, $target_lang, $unique_lines_in_eng_constitution); $constitution_readable = $lang_constitution_results['constitution_readable']; $diff['untranslated_lines_in_constitution'] = $lang_constitution_results['untranslated_lines_in_constitution']; // add untranslated license sentences $dest_constitution = sprintf('%s/%s_%s.md', 'href="//svnweb.mageia.org/web/www/trunk/en/about/constitution', 'mageia.org_statutes', ($constitution_readable ? $target_lang : 'en')); @@ -129,7 +139,7 @@ header('Content-Type: text/html;charset=utf-8'); Differences between %s source and %s target', - substr($source_file, strpos($source_file, '/langs/')+7), $target_lang); ?> + $source_file, $target_lang); ?> -- cgit v1.2.1