diff options
Diffstat (limited to 'langs/diff.php')
-rw-r--r-- | langs/diff.php | 157 |
1 files changed, 0 insertions, 157 deletions
diff --git a/langs/diff.php b/langs/diff.php deleted file mode 100644 index 9986bf1b2..000000000 --- a/langs/diff.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -/** - * Report the diff of 's' file - * against matching file in language 'l', if it exists. -*/ -define('HLANG', true); -include 'lib.php'; - -$source_file = isset($_GET['s']) ? strip_tags(trim($_GET['s'])) : null; -$target_lang = isset($_GET['l']) ? strip_tags(trim($_GET['l'])) : null; - -if (is_null($source_file) || - is_null($target_lang)) { - - die('kthxbai'); -} - -if (!file_exists($source_file)) { - die('no source'); -} - -$resource = _extract_resource($source_file); -$target_file = _po_file_switch($source_file, $target_lang); - -if (!file_exists($target_file)) { - die('no target'); -} - -if($resource =='about/constitution') { - $constitution = true; -} else { - $constitution = false; -} - -if($resource =='about/license') { - $license = true; -} else { - $license = false; -} - -if (false !== strstr($source_file, '../_nav/langs/en.')) { - $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="http://gitweb.mageia.org/web/nav/tree/langs/' . $file . '">/langs/' . $file . '</a>'; -} else { - $file = $target_file; - $note = ''; - $commit = '<a href="http://gitweb.mageia.org/web/www/tree/langs/' . $file . '">/langs/' . $file . '</a>'; -} - -$source_file_path = realpath($source_file); -$target_file_path = realpath($target_file); - -if (false === strstr($source_file_path, '/langs/') || - false === strstr($target_file_path, '/langs/')) { - die('no sorry'); -} - -$diff = _po_diff($target_lang, $resource); - -$issues = array( - 'missing' => 'missing string', - 'fuzzy_or_missing' => 'fuzzy or missing string', - 'notrans' => 'untranslated string', - 'extra' => 'unused (old) string', - 'dup_str' => 'duplicate string', -); - -$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>', - $source_file, $target_lang); - -$s .= '<p>You can translate most of our web page resources online in <a href="http://www.transifex.com/organization/MageiaLinux/dashboard/all_resources/' . $target_lang . '/#1/?c=Webpages">Transifex</a>.</p>'; -$s .= '<p>Please take a look off the translation guide on the <a href="https://wiki.mageia.org/en/Internationalisation_Team_(i18n)#Website_translation">localization Wiki page</a> too.</p>'; - -$additional_file = ''; - -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="http://gitweb.mageia.org/web/www/tree/en/about/constitution/">git</a>. '; - - $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(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="http://gitweb.mageia.org/web/www/tree/en/about/constitution', 'mageia.org_statutes', ($constitution_readable ? $target_lang : 'en')); - $issues['untranslated_lines_in_constitution'] = 'of all untranslated lines in separate <a ' . $dest_constitution . '>constitution md format file</a>'; - $additional_file = "\t\t<li>same goes for <a $dest_constitution>constitution</a></li>"; -} - -if($license) { - require_once('../en/about/license/license.php'); - $license_array = read_license_from_vcs($target_lang); - $license_numbers = array_pop($license_array); - $num_of_untranslated_strings = $license_numbers["untran"]; // number of all license sentences - $diff['untranslated_sentences_in_license'] = $license_numbers['untranslated_sentences']; // add untranslated license sentences - $s .= '<h2 style="color: red;">Please translate <a href="http://gitweb.mageia.org/software/drakx/tree/perl-install/share/po/' . $target_lang . '.po">separate license file</a> fully into ' . $langs[$target_lang] . ' first</h2>'; - $s .= sprintf('<p>You can find it as a part of a separate <a href="http://gitweb.mageia.org/software/drakx/tree/perl-install/share/po/' . $target_lang . '.po">drakx translation file in git</a> or in <a href="https://www.transifex.com/organization/MageiaLinux/dashboard/all_resources/' . $target_lang . '/#1/?s=drakx_share">Transifex</a>. ', $target_lang); // git doesn't work yet on https - $issues['untranslated_sentences_in_license'] = 'untranslated msgid strings in ' . $num_of_untranslated_strings . ' license sentences as a part of a separate <a href="http://gitweb.mageia.org/software/drakx/tree/perl-install/share/po/' . $target_lang . '.po">drakx translation file</a> (it starts before the line with the string "1. License Agreement")'; -} - -if($constitution || $license) { - $s .= 'Please read <a href="https://wiki.mageia.org/en/Internationalisation_Team_%28i18n%29#Special_cases_of_web_pages">page on wiki for more information</a> about that.</p>'; -} - -$s .= '<p>After translation:</p>'; -$s .= "\t<ul>"; -$s .= "\t\t<li>if you're in <a href=\"http://people.mageia.org/g/mga-i18n-committers.html\">mga-i18n-committers group</a>,"; -$s .= " you may commit updated po file directly in <code>$commit.</code>$note</li>"; -$s .= "\t\t<li>or attach it to a mail to <a href=\"https://ml.mageia.org/l/info/i18n-discuss\">Mageia localization team</a> (<code>mageia-i18n</code>, <a href=\"irc://irc.freenode.net/#mageia-i18n\">#mageia-i18n</a> on Freenode).</li>"; -$s .= $additional_file; -$s .= "\t</ul>"; - -$new_line = "\n\n"; -$filename = ' in ' . $commit; // $file -$title_prefix = 'Report found '; -foreach ($issues as $type => $name) { - if (isset($diff[$type]) && count($diff[$type]) > 0) { - if ($type == 'untranslated_lines_in_constitution') { - $prefix = ''; - $new_line = "\n"; - $filename = ''; - } else if ($type == 'untranslated_sentences_in_license') { - $prefix = 'msgid: '; - $filename = ''; - } else { - $prefix = ';'; - } - $s .= sprintf('<h2>%s %d %s%s:</h2>', $title_prefix, count($diff[$type]), $name . ((count($diff[$type]) > 1) ? 's' : ''), $filename); - $s .= '<pre>'; - foreach ($diff[$type] as $l) - $s .= sprintf("%s%s%s", $prefix, rtrim(htmlspecialchars($l)), $new_line); // cut at 200: substr(rtrim(htmlspecialchars($l)), 0, 200) - $s .= '</pre>'; - $filename = ''; - $title_prefix = 'and also '; - } -} - -header('Content-Type: text/html;charset=utf-8'); - -?><!DOCTYPE html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <meta name="robot" content="noindex,nofollow,nosnippet"> - <?php echo sprintf('<title>Differences between %s source and %s target</title>', - $source_file, $target_lang); ?> - <style> - pre { background: #eee; padding: 0.6em; } - </style> -</head> -<body> - <?php echo $s; ?> -<hr> -</body> -</html> |