From 623ce3a295aae5d1258567c2a2db151a3d621976 Mon Sep 17 00:00:00 2001 From: Filip Komar Date: Mon, 13 Jan 2014 17:51:23 +0000 Subject: some code optimisation --- langs/diff.php | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'langs/diff.php') diff --git a/langs/diff.php b/langs/diff.php index c7a2cb368..f7e87839f 100644 --- a/langs/diff.php +++ b/langs/diff.php @@ -59,11 +59,17 @@ if (false === strstr($source_file, '/langs/') || $diff = _lang_diff($source_file, $target_file); +$issues = array( + 'missing' => 'missing strings', + 'notrans' => 'untranslated strings', + 'extra' => 'unused (old) strings', + 'dup_str' => 'duplicate strings', +); + $s = '« back to langs report'; $s .= sprintf('

Differences between %s source and %s target

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

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

'; $s .= '

You can find it in svn. '; @@ -72,15 +78,11 @@ if($constitution) { $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); $constitution_readable = $lang_constitution_results['constitution_readable']; - if ($constitution_readable) { - $diff['untranslated_lines_in_constitution'] = $lang_constitution_results['untranslated_lines_in_constitution']; // add untranslated license sentences - } else { - $diff['untranslated_lines_in_constitution'] = $lang_constitution_results['untranslated_lines_in_constitution']; // add untranslated license sentences - } + $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)'; } -$num_of_untranslated_strings = 0; -$diff['untranslated_sentences_in_license'] = array(); if($license) { require_once('../en/about/license/license.php'); $license_numbers = array_pop(read_license_from_vcs($target_lang)); @@ -88,6 +90,7 @@ 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)'; } if($constitution || $license) { @@ -100,18 +103,7 @@ $s .= '

After translation:

  • or attach it to a mail to Mageia localization team (mageia-i18n, #mageia-i18n on Freenode).
  • '; -$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 = array( - 'missing' => 'missing strings', - 'notrans' => 'untranslated strings', - 'extra' => 'unused (old) strings', - 'dup_str' => 'duplicate strings', - 'untranslated_lines_in_constitution' => 'of all untranslated lines in constitution (in svn)', - 'untranslated_sentences_in_license' => 'untranslated msgid strings in ' . $num_of_untranslated_strings . ' sentences in separate license file (in git)', -); foreach ($issues as $type => $name) { - if (count($diff[$type]) > 0) { $s .= sprintf('

    %d %s:

    ', count($diff[$type]), $name); $s .= '
    ';
    -- 
    cgit v1.2.1