diff options
author | Filip Komar <filip@mageia.org> | 2014-03-07 22:01:48 +0000 |
---|---|---|
committer | Filip Komar <filip@mageia.org> | 2014-03-07 22:01:48 +0000 |
commit | 42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c (patch) | |
tree | 7e10eef85c8b84006d19e900f1b95d180aa80a93 /langs/diff.php | |
parent | 51ff78de21924eb125b7fb0d8aace4fc43789253 (diff) | |
download | www-42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c.tar www-42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c.tar.gz www-42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c.tar.bz2 www-42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c.tar.xz www-42fa789ce0ea2df5240c17e0ea35e2a1f1a6742c.zip |
first steps as a preparation of l10n report (only diff.php for now - 3 exceptions) to gettext system
Diffstat (limited to 'langs/diff.php')
-rw-r--r-- | langs/diff.php | 42 |
1 files changed, 26 insertions, 16 deletions
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 = '<span style="color: red; font-weight: bold"> NOTE: THIS IS TRANSLATION OF NAVIGATION SO LOCATION FOR COMMIT IS DIFFERENT!</span>'; $commit = '<a href="//svnweb.mageia.org/web/www/trunk/_nav/langs/' . $file . '?view=markup">web/www/trunk/_nav/langs/' . $file . '</a> and for now to the <a href="//svnweb.mageia.org/web/nav/langs/' . $file . '?view=markup">web/nav/langs/' . $file . '</a> too'; } else { - $file = _lang_file_switch($source_file, $target_lang); + $file = $target_file; $note = ''; $commit = '<a href="//svnweb.mageia.org/web/www/trunk/langs/' . $file . '?view=markup">web/www/trunk/langs/' . $file . '</a>'; } -$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 = '<a href="report.php?l=' . $target_lang . '">« back to the report page for ' . $langs[$target_lang] . '</a>'; $s .= sprintf('<h1>Differences between %s source and %s target</h1>', - substr($source_file, strpos($source_file, '/langs/')+7), $target_lang); + $source_file, $target_lang); if($constitution) { $s .= '<h2 style="color: red;">Please translate constitution fully into ' . $langs[$target_lang] . ' first</h2>'; $s .= '<p>You can find it in <a href="//svnweb.mageia.org/org/constitution/">svn</a>. '; - $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'); <meta charset="utf-8"> <meta name="robot" content="noindex,nofollow,nosnippet"> <?php echo sprintf('<title>Differences between %s source and %s target</title>', - substr($source_file, strpos($source_file, '/langs/')+7), $target_lang); ?> + $source_file, $target_lang); ?> <style> pre { background: #eee; padding: 0.6em; } </style> |