From d7a6abb861c0afe10ac535d131e6e77bc50b9a0c Mon Sep 17 00:00:00 2001 From: filip Date: Fri, 1 Aug 2014 22:41:44 +0200 Subject: transition of diff.php to gettext only, move from svn to git, minor improvements --- langs/diff.php | 58 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/langs/diff.php b/langs/diff.php index 251cd87f0..f86038f41 100644 --- a/langs/diff.php +++ b/langs/diff.php @@ -19,15 +19,8 @@ if (!file_exists($source_file)) { die('no source'); } -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); -} +$resource = _extract_resource($source_file); +$target_file = _po_file_switch($source_file, $target_lang); if (!file_exists($target_file)) { die('no target'); @@ -48,11 +41,11 @@ if($resource =='about/license') { if (false !== strstr($source_file, '../_nav/langs/en.')) { $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'; + $commit = '/langs/' . $file . ''; } else { $file = $target_file; $note = ''; - $commit = 'web/www/trunk/langs/' . $file . ''; + $commit = '/langs/' . $file . ''; } $source_file_path = realpath($source_file); @@ -63,11 +56,7 @@ if (false === strstr($source_file_path, '/langs/') || die('no sorry'); } -if ($gettext) { - $diff = _po_diff($target_lang, $resource); -} else { - $diff = _lang_diff($source_file_path, $target_file_path); -} +$diff = _po_diff($target_lang, $resource); $issues = array( 'missing' => 'missing strings', @@ -81,17 +70,23 @@ $s = '« back to the report pag $s .= sprintf('

Differences between %s source and %s target

', $source_file, $target_lang); +$s .= '

You can translate most of our web page resources online in Transifex.'; +$s .= ' More info in our Wiki.

'; + +$additional_file = ''; + if($constitution) { $s .= '

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

'; - $s .= '

You can find it in svn. '; + $s .= '

You can find it in git. '; $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="//svnweb.mageia.org/web/www/trunk/en/about/constitution', 'mageia.org_statutes', ($constitution_readable ? $target_lang : 'en')); - $issues['untranslated_lines_in_constitution'] = 'of all untranslated lines in constitution (in svn)'; + $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 constitution md format file'; + $additional_file = "\t\t

  • same goes for constitution
  • "; } if($license) { @@ -102,32 +97,39 @@ if($license) { $diff['untranslated_sentences_in_license'] = $license_numbers['untranslated_sentences']; // add untranslated license sentences $s .= '

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

    '; $s .= sprintf('

    You can find it in git. ', $target_lang); // git doesn't work yet on https - $issues['untranslated_sentences_in_license'] = 'untranslated msgid strings in ' . $num_of_untranslated_strings . ' sentences in separate license file (in git)'; + $issues['untranslated_sentences_in_license'] = 'untranslated msgid strings in ' . $num_of_untranslated_strings . ' license sentences as part of a separate drakx file (look below line 4 500)'; } if($constitution || $license) { $s .= 'Please read page on wiki for more information about that.

    '; } -$s .= '

    After translation:

    - '; +$s .= '

    After translation:

    '; +$s .= "\t"; +$new_line = "\n\n"; foreach ($issues as $type => $name) { if (isset($diff[$type]) && count($diff[$type]) > 0) { - $s .= sprintf('

    %d %s:

    ', count($diff[$type]), $name); - $s .= '
    ';
    +        $filename = ' in ' . $commit; // $file
             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('

    %d %s%s:

    ', count($diff[$type]), $name, $filename); + $s .= '
    ';
             foreach ($diff[$type] as $l)
    -            $s .= sprintf("%s%s\n\n", $prefix, rtrim(htmlspecialchars($l)));
    +            $s .= sprintf("%s%s%s", $prefix, rtrim(htmlspecialchars($l)), $new_line); // cut at 200: substr(rtrim(htmlspecialchars($l)), 0, 200)
             $s .= '
    '; } } -- cgit v1.2.1