summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-02-13 21:17:26 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-02-13 21:17:26 +0000
commitb5fcdb259c3131ee7f5379f324fa0767657e0515 (patch)
tree45b5660dd00a0a03206289c2bb0089c4db2396db /mdk-stage1
parent6a8efaf86001393b62802af5b07f777f425f0fb9 (diff)
downloaddrakx-b5fcdb259c3131ee7f5379f324fa0767657e0515.tar
drakx-b5fcdb259c3131ee7f5379f324fa0767657e0515.tar.gz
drakx-b5fcdb259c3131ee7f5379f324fa0767657e0515.tar.bz2
drakx-b5fcdb259c3131ee7f5379f324fa0767657e0515.tar.xz
drakx-b5fcdb259c3131ee7f5379f324fa0767657e0515.zip
use exit code 66 for rescue
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/init.c9
-rw-r--r--mdk-stage1/stage1.c4
2 files changed, 7 insertions, 6 deletions
diff --git a/mdk-stage1/init.c b/mdk-stage1/init.c
index 2ea86be09..87cd2df65 100644
--- a/mdk-stage1/init.c
+++ b/mdk-stage1/init.c
@@ -309,6 +309,7 @@ void unmount_filesystems(void)
}
}
+int exit_value_rescue = 66;
int main(int argc, char **argv)
{
@@ -402,18 +403,18 @@ int main(int argc, char **argv)
end_stage2 = 1;
}
- if (!WIFEXITED(wait_status) || (WEXITSTATUS(wait_status) != 0 && WEXITSTATUS(wait_status) != 1)) {
+ if (!WIFEXITED(wait_status) || (WEXITSTATUS(wait_status) != 0 && WEXITSTATUS(wait_status) != exit_value_rescue)) {
printf("install exited abnormally :-( ");
if (WIFSIGNALED(wait_status))
printf("-- received signal %d", WTERMSIG(wait_status));
printf("\n");
abnormal_termination = 1;
- } else if (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == 1) {
+ } else if (WIFEXITED(wait_status) && WEXITSTATUS(wait_status) == exit_value_rescue) {
kill(klog_pid, 9);
- printf("exiting stage1-initializer -- giving hand to rescue\n");
+ printf("exiting init -- giving hand to rescue\n");
return 0;
} else
- printf("back to stage1-initializer control (install succeeded)\n");
+ printf("install succeeded\n");
if (testing)
return 0;
diff --git a/mdk-stage1/stage1.c b/mdk-stage1/stage1.c
index 8de538126..e0e5f76a8 100644
--- a/mdk-stage1/stage1.c
+++ b/mdk-stage1/stage1.c
@@ -214,7 +214,7 @@ static void expert_third_party_modules(void)
strcat(final_name, choice);
- results = ask_from_entries("Please enter the options:", questions, &answers, 24);
+ results = ask_from_entries("Please enter the options:", questions, &answers, 24, NULL);
if (results != RETURN_OK) {
umount(floppy_mount_location);
return expert_third_party_modules();
@@ -368,7 +368,7 @@ int main(int argc, char **argv, char **env)
write(fd, "0x103", sizeof("0x103")); /* ram3 */
#endif
close(fd);
- return 1;
+ return 66;
}
if (IS_TESTING)
1 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex,nofollow,nosnippet">
    <title>www.mageia.org report about differences between Transifex and our git repository</title>
    <style>
        html, body { margin: 0; padding: 0; font-family: Verdana, "Trebuchet MS", "Lucida Grande", "Lucida Sans", Verdana, Tahoma, Arial, sans-serif; }
        table, th, td {
            border:1px solid gray;
            border-collapse:collapse;
        }
        th { text-align: left; }
        td, th { font-size: 80%; padding: 0.3em; }
        li { padding: 3px; }
        #page { padding: 1em; position: absolute; top: 128px; }
        .add { color: black; background: lightgrey; }
        .bold { font-weight: bold; }
        .stat { font-size: smaller; }
        .italic { font-style:italic; }
    </style>
</head>
<body class="contribute">
    <header id="mgnavt">
        <h1><a href="//www.mageia.org/">www.mageia.org</a> report about differences between Transifex and our git repository</h1>
        <ul>
            <li> </li>
        </ul>
    </header>
    <div id="page">

    <p>Languages translation progress report for web pages is available <a href="./report.php">here</a>.</p>

<?php
define('HLANG', TRUE);
include 'lib.php';

$errors = array(); // stored for error management ;)
$wanted_category = get_sane_string('c');
if (in_array($wanted_category, array('Webpages', 'Documentation', 'Cauldron'))) {
    $resource_type = $wanted_category; // filter only valid resource types
} else {
    $resource_type = 'Webpages'; // default
}
$wanted_language   = get_sane_string('l');
$wanted_lang_name  = '';
if (!empty($wanted_language)) {
    $wanted_lang_name  = get_language_name($wanted_language) . " (";
    $wanted_lang_name .= build_transifex_link($wanted_language, NULL, $resource_type) . ")";
}
// NOTE: there is a different naming convention between Tx and git for some lanuages:
//      Tx              git
//      sr@latin    vs. sr@Latn.po
//      sr@latin    vs. sr@latin.po     exception: http://gitweb.mageia.org/software/i18n/system-config-printer/plain/po
//      uz@Cyrl     vs. uz@cyrillic.po
//      en_GB       vs. en_gb.po        exception: http://gitweb.mageia.org/web/identity/plain/lib/CatDap/I18N
$wanted_resource = get_sane_string('r');
$wanted_resource_name = '';
if (!empty($wanted_resource)) {
    $wanted_resource_name = str_replace(array('../_nav/langs/en', 'en/', '.pot'), array('nav', '', ''), $wanted_resource);
}

include 'resources_list.php';

// get resources data from TX
$tx_resources = tx_call("resources");

$details_wanted = FALSE;
if (!empty($wanted_language) && !empty($wanted_resource_name)) {
    $details_wanted = TRUE;
}

$parsed_tx_file_content = NULL;
if ($details_wanted) {
    $prefixed_resource_name = resource_name_conversion($wanted_resource_name, $wanted_category);
    $tx_file = tx_call("resource/$prefixed_resource_name/translation/$wanted_language/");
    if (!empty($tx_file)) {
        $tx_file_content = $tx_file['content'];
        $tx_file_content = explode("\n", $tx_file_content);
        if ('mageiasync' == $wanted_resource_name) { // treat TS files differently
            $parsed_tx_file_content = _parse_ts_file($tx_file_content, FALSE);
        } else {
            $parsed_tx_file_content = phpmo_parse_po_file($tx_file_content, FALSE);
        }
    }
}

// create separate array ($tx_resources_info) and add statistics to it from TX
$tx_resources_info     = array();
$tx_cauldron_resources = array();
$tx_stat_for_resource  = array();
foreach ($tx_resources as $one_resource) {
    $tx_resource_name = $one_resource['slug'];
    $category         = $one_resource['categories'][0];
    $add_data         = FALSE;
    if ('Cauldron' == $category) {
        $tx_cauldron_resources[] = $tx_resource_name;
    }
    // limit resource type to one
    if ($category == $resource_type) {
        if ('Cauldron' == $category) { // add data for Cauldron category
            // if name is required
            if (!empty($wanted_resource) && $tx_resource_name == resource_name_conversion($wanted_resource_name, $category)) {
                $add_data = TRUE;
            // if only language is required
            } else if (!empty($wanted_language) && empty($wanted_resource)) {
                $add_data = TRUE;
            }
        } else { // add data for Webpages and Documentation category
            if (empty($wanted_resource) && empty($wanted_language)) {
                $add_data = TRUE;
            }
        }
        // add data if details are needed
        if ($details_wanted && $tx_resource_name == resource_name_conversion($wanted_resource_name, $category)) {
            $add_data = TRUE;
        }
    }
    if ($add_data) {
        // add statistic
        if (empty($wanted_language)) {
            $tx_stat_for_resource = tx_call("resource/$tx_resource_name/stats");
        } else {
            $tx_stat_for_resource[$wanted_language] = tx_call("resource/$tx_resource_name/stats/$wanted_language");
        }
        $tx_resource_name = str_replace('page-', '', $tx_resource_name); // unify resource names
        $one_resource['tx_resource_name'] = $tx_resource_name;
        $one_resource['statistic']        = $tx_stat_for_resource;
        $tx_resources_info[$tx_resource_name] = $one_resource;
    }
}
$tx_languages = array();
if (empty($wanted_language)) {
    if ('Webpages' == $resource_type || 'Documentation' == $resource_type) {
        $tx_stat_for_resource = tx_call("resource/page-index/stats");
        $tx_languages = array_keys($tx_stat_for_resource);
    } else {
        foreach ($tx_stat_for_resource as $tx_resource_language => $tx_resource_language_stat) {
            $tx_languages[] = $tx_resource_language;
        }
    }
} else {
    $tx_stat_for_resource = tx_call("resource/$tx_resource_name/stats");
    $tx_languages = array_keys($tx_stat_for_resource);
}

// create array ($report) with statistics from git
$report = array();
if ('Webpages' == $resource_type) {
    if (empty($wanted_resource) && empty($wanted_language)) {
        $enFiles = array_merge(array('../_nav/langs/en.pot'), get_lang_references('*.pot')); // added navigation file
        $report = generating_report(get_other_langs(), $enFiles);
    } else {
        $enFiles = array($wanted_resource);
        $report = generating_report(array($wanted_language), $enFiles, NULL, NULL, $parsed_tx_file_content);
    }
} else {
    $tx_resources_not_yet_in_git = array();
    $translated_in_tx = ' translated in Transifex';
    foreach ($git_resources as $git_resource_details) {
        $tx_name  = $git_resource_details['tx_name'];
        if (!empty($wanted_resource) && $tx_name != $wanted_resource) {
            continue;
        }
        $git_path = $git_resource_details['git_path'];
        $pot_name = $git_resource_details['pot_name'];
        $raw_html_dump = file_get_contents($git_path);
        if (FALSE === $raw_html_dump) {
            $errors['file_get_contents_failed'] = "Access to $git_path failed.";
        }
        // list all po files from links within $raw_html_dump
        if (false !== strpos($pot_name, '_en.ts')) { // treat TS files differently
            $first_part_pot_name = substr($pot_name, 0, -5); // cuts 'en.ts' from mageiaSync_en.ts
            preg_match_all("/('>$first_part_pot_name)([a-z_A-Z0-9@-]+)(\.ts<)/", $raw_html_dump, $language_codes);
        } else {
            preg_match_all("/('>)([a-z_A-Z0-9@-]+)(\.po<)/", $raw_html_dump, $language_codes);
        }
        $git_language_codes = $language_codes[2];
        if (empty($wanted_language)) {
            $report_language_codes = $git_language_codes;
        } else {
            if (in_array($wanted_language, $git_language_codes)) {
                $report_language_codes = array($wanted_language);
            } else {
                $report_language_codes = array();
                $completion  = $tx_resources_info[$tx_name]['statistic'][$wanted_language]['completed'];
                $completion .= $translated_in_tx;
                $translated_in_tx = '';
                $tx_resources_not_yet_in_git[] = "$tx_name ($completion)";
                $resources_not_yet_in_git = implode(", ", $tx_resources_not_yet_in_git);
                $errors['lang_not_in_git'] = "Language $wanted_lang_name is not present in git for $resources_not_yet_in_git resource.";
            }
        }
        $one_report = generating_report(array_values($report_language_codes), array($tx_name), $git_path, $pot_name, $parsed_tx_file_content);
        $report = array_merge($one_report, $report);
    }
}

// core part: building the data
$tx_lang_completed_treshold  = 75; // report new languages above this treshold from 0 to 100 (%)
$langs_and_res_names_done    = FALSE;
$tx_all_languages            = array();
$tx_all_langs_above_treshold = array();
$git_all_languages           = array();
$tx_all_resource_names       = array();
$git_all_resource_names      = array();
$git_compare_resources       = array();
$tx_git_difference           = array();
$parse_errors                = array();
$nonequal_num_of_all_strings = array();
foreach ($tx_resources_info as $tx_resource_info) {
    $tx_resource_name        = $tx_resource_info['tx_resource_name'];
    if (!in_array($tx_resource_name, $tx_all_resource_names)) {
        $tx_all_resource_names[] = $tx_resource_name;
    }
    foreach ($tx_resource_info['statistic'] as $tx_resource_language => $tx_resource_language_stat) {
        if (array_key_exists('completed', $tx_resource_language_stat)) {
            $completed = sprintf("%d", $tx_resource_language_stat['completed']);
        } else {
            $completed = 0;
        }
        if (!in_array($tx_resource_language, $tx_all_languages)) {
            $tx_all_languages[] = $tx_resource_language;
        }
        if ($tx_lang_completed_treshold <= $completed && 'en' != $tx_resource_language) {
            $tx_all_langs_above_treshold[$tx_resource_language][] = $tx_resource_name;
        }
        foreach ($report as $git_resource_info) {
            $git_resource_name         = $git_resource_info['resource_name'];
            $git_compare_resource_name = str_replace('/', '-', $git_resource_name);
            $git_resource_language     = $git_resource_info['web_language_code'];
            if (!$langs_and_res_names_done) {
                $git_all_languages[]      = $git_resource_language;
                $git_all_resource_names[] = $git_resource_name;
                $git_compare_resources[]  = $git_compare_resource_name;
            }
            // if names and languages match but skip English as a source language
            if ($tx_resource_language == $git_resource_language && 'en' != $git_resource_language 
                && $tx_resource_name == $git_compare_resource_name) {

                if (array_key_exists('untranslated_entities', $tx_resource_language_stat)) {
                    $tx_resource_untrans_in_lang     = $tx_resource_language_stat['untranslated_entities'];
                    $tx_resource_all_strings_in_lang = $tx_resource_untrans_in_lang + $tx_resource_language_stat['translated_entities'];
                } else {
                    $tx_resource_untrans_in_lang     = 0;
                    $tx_resource_all_strings_in_lang = 0;
                }

                $git_resource_num_of_all_strings = $git_resource_info['num_of_all_strings'];
                $git_resource_untrans_in_lang    = $git_resource_info['num_of_not_fully_trans'];
                $git_resource_path               = $git_resource_info['webgit_path'];
                $git_resource_pot_name           = $git_resource_info['pot_name'];
                $git_resource_differences        = $git_resource_info['differences'];

                // compare l10n level or differences
                if ($tx_resource_untrans_in_lang != $git_resource_untrans_in_lang || count($git_resource_differences) != 0) {
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['tx_num_of_all_strings'] = $tx_resource_all_strings_in_lang;
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['tx_untranslated']       = $tx_resource_untrans_in_lang;
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['git_untranslated']      = $git_resource_untrans_in_lang;
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['webgit_path']           = $git_resource_path;
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['pot_name']              = $git_resource_pot_name;
                    $tx_git_difference[$tx_resource_language][$git_resource_name]['differences']           = $git_resource_differences;
                }
                // it seems like a parse error
                if (0 == $git_resource_num_of_all_strings) {
                    $parse_errors[$git_resource_name][] = $git_resource_language;
                // this below should normaly only happen inside of a tx sync window so remember it
                } else if ($tx_resource_all_strings_in_lang != $git_resource_num_of_all_strings) {
                    if (!array_key_exists($git_resource_name, $nonequal_num_of_all_strings)) {
                        $nonequal_num_text = "$git_resource_name git:$git_resource_num_of_all_strings/tx:$tx_resource_all_strings_in_lang";
                        $nonequal_num_of_all_strings[$git_resource_name] = $nonequal_num_text;
                    }
                }
            }
        }
        if (!$langs_and_res_names_done) {
            $git_all_languages        = array_unique($git_all_languages);
            $git_all_resource_names   = array_unique($git_all_resource_names);
            $git_compare_resources    = array_unique($git_compare_resources);
            $langs_and_res_names_done = TRUE;
        }
    }
};

// sorting data
sort($tx_all_resource_names, SORT_STRING);
sort($git_all_resource_names, SORT_STRING);
sort($git_compare_resources, SORT_STRING);
sort($tx_all_languages);
ksort($tx_all_langs_above_treshold); // sort by lang
sort($git_all_languages);
sort($nonequal_num_of_all_strings, SORT_STRING);

$tx_all_resources_above_treshold = array();
foreach ($tx_all_langs_above_treshold as $tx_only_language => $resource_above_treshold_for_lang) {
    foreach ($resource_above_treshold_for_lang as $resource_above_treshold) {
        $tx_all_resources_above_treshold[] = $resource_above_treshold;
    }
}
$tx_all_resources_above_treshold = array_unique($tx_all_resources_above_treshold);
sort($tx_all_resources_above_treshold, SORT_STRING);

$tx_only_resources  = array_diff($tx_all_resources_above_treshold, $git_compare_resources);
$git_only_resources = array_diff($git_compare_resources, $tx_all_resource_names);
$tx_only_languages  = array_diff(array_keys($tx_all_langs_above_treshold), $git_all_languages);
$git_only_languages = array_diff($git_all_languages, $tx_all_languages);

// preparing text for languages not present yet in our git repositories
$tx_only_languages_details = '';
if (0 < count($tx_only_languages)) {
    if (!empty($wanted_language) && !empty($wanted_resource)) {
        $tx_only_languages_details = "<h3>Language $wanted_lang_name with $wanted_resource resource for $resource_type translated over treshold ";
    } else if (!empty($wanted_language) && empty($wanted_resource)) {
        $tx_only_languages_details = "<h3>Language $wanted_lang_name with at least one resource for $resource_type translated over treshold ";
    } else if (empty($wanted_language) && !empty($wanted_resource)) {
        $tx_only_languages_details = "<h3>Languages with $wanted_resource resource for $resource_type translated over treshold ";
    } else {
        $tx_only_languages_details = "<h3>Languages with at least one resource for $resource_type translated over treshold ";
    }
    $tx_only_languages_details .= "($tx_lang_completed_treshold %) in Transifex but not present yet in our git:</h3><ul>";
    foreach ($tx_only_languages as $tx_only_language) {
        $language_name = get_language_name($tx_only_language);
        $tx_only_languages_details .= '<li><span class="bold">' . $language_name . '</span>: ';
        if (empty($wanted_resource)) {
            $tx_only_languages_details .= build_transifex_link($tx_only_language, NULL, $resource_type);
            $tx_only_languages_details .= " (resources over treshold: ";
            $resources_above_treshold = array();
            foreach ($tx_all_langs_above_treshold[$tx_only_language] as $resource_above_treshold) {
                $level = $tx_resources_info[$resource_above_treshold]['statistic'][$tx_only_language]['completed'];
                $resources_above_treshold[] = "$resource_above_treshold at $level";
            }
            sort($resources_above_treshold, SORT_STRING);
            $tx_only_languages_details .= implode(", ", $resources_above_treshold) . ")";
        } else {
            $tx_only_languages_details .= build_transifex_link($tx_only_language, $tx_only_language, $resource_type, $wanted_resource);
            $level = $tx_resources_info[$wanted_resource]['statistic'][$tx_only_language]['completed'];
            $tx_only_languages_details .= " ($level translated)";
        }
        $tx_only_languages_details .= ",</li>";
    }
    $tx_only_languages_details .= '</ul>';
}

// preparing error texts
if (0 < count($git_only_languages)) {
    $error                        = "Note that some languages (" . implode(", ", $git_only_languages) . ") are present in our git";
    $errors['git_only_languages'] = "$error but they are below treshold ($tx_lang_completed_treshold %) in Transifex.";
}

if (0 < count($git_only_resources)) {
    $error                        = "Some resources (" . implode(", ", $git_only_resources) . ") are present only in our git";
    $errors['git_only_resources'] = "$error but not in Transifex. Please report that.";
}

if (0 < count($parse_errors)) {
    $errors_in_parsing            = array();
    foreach ($parse_errors as $single_git_resource_name => $git_resource_languages) {
        $errors_in_parsing[]      = "$single_git_resource_name.po (languages: " . implode(", ", $git_resource_languages) . ")";
    }
    $reload                       = "Please reload the page later and report this on mailing list if it persist.";
    $errors['po_file_parse']      = "It seems that parsing of some resources failed: " . implode(", ", $errors_in_parsing) . ". $reload";
}

if (0 < count($nonequal_num_of_all_strings)) {
    $error                                 = "Some resources (" . implode(", ", $nonequal_num_of_all_strings) . ") ";
    $error                                .= "have different number of all strings between our git and Transifex.";
    $errors['nonequal_num_of_all_strings'] = "$error Please report that on the mailing list if it happens across several days.";
}

// making a list of resources with Tx/git differences
ksort($tx_git_difference);
$all_resources_with_tx_git_diff = array();
foreach ($tx_git_difference as $one_language_of_tx_git_difference => $resources_with_tx_git_difference) {
//     $all_languages_with_tx_git_diff[] = $one_language_of_tx_git_difference;
    foreach ($resources_with_tx_git_difference as $one_resource_with_tx_git_difference => $details) {
        $all_resources_with_tx_git_diff[] = $one_resource_with_tx_git_difference;
    }
}
$all_resources_with_tx_git_diff = array_unique($all_resources_with_tx_git_diff);
sort($all_resources_with_tx_git_diff, SORT_STRING);

// preparing a detailed strings difference html table represantation between git and tx
if ($details_wanted) {
    $table_rows   = array();
    $table_rows[] = "<table>" . PHP_EOL;
    $table_rows[] = "<thead>" . PHP_EOL;
    $table_rows[] = "<tr class=\"add\"><th>Original string</th><th>Translated string from git</th><th>And translated string from Transifex</th></tr>" . PHP_EOL; // add header row
    $table_rows[] = "</thead>" . PHP_EOL;
    $table_rows[] = "<tbody>" . PHP_EOL;
    $num_of_differences = 0;
    $col_repeat = 8;
    $i = 0;
    foreach ($tx_git_difference as $one_language => $one_language_array) {
        $differences = $one_language_array[$wanted_resource_name]['differences'];
        $num_of_differences = count($differences);
        foreach ($differences as $curr_msgid => $curr_context_array) {
            foreach ($curr_context_array as $curr_context_or_num => $array_for_compare) {
                if (is_string($curr_context_or_num)) {
                    $curr_msgid .= " (Context: $curr_context_or_num)";
                }
                $curr_msgid = htmlentities($curr_msgid, null, 'UTF-8');
                $num_of_tr_str = max(count($array_for_compare['target_l']), count($array_for_compare['compared'])) - 1;
                for ($i = 0; $i <= $num_of_tr_str; $i++) {
                    if (empty($array_for_compare['target_l'][$i])) {
                        $target_l_str = '&nbsp;';
                    } else {
                        $target_l_str = htmlentities($array_for_compare['target_l'][$i], null, 'UTF-8');
                    }
                    if (empty($array_for_compare['compared'][$i])) {
                        $compared_str = '&nbsp;';
                    } else {
                        $compared_str = htmlentities($array_for_compare['compared'][$i], null, 'UTF-8');
                    }
                    $row  = "<tr><td class=\"add\">$curr_msgid</td>";
                    $row .= "<td>$target_l_str</td>";
                    $row .= "<td>$compared_str</td></tr>";
                    $table_rows[] = $row . PHP_EOL;
                    // instead of msgid use msgid_plural for plural table lines
                    if (is_array($array_for_compare['target_l'])) {
                        if (array_key_exists('msgid_plural', $array_for_compare['target_l'])) {
                            $curr_msgid = str_replace($curr_msgid, $array_for_compare['target_l']['msgid_plural'], $curr_msgid);
                        }
                    }
                }
            }
        }
    }
    $table_rows[] = "</tbody>" . PHP_EOL;
    $table_rows[] = "</table>" . PHP_EOL;

    if (0 != $num_of_differences) {
        $table_w_details = implode($table_rows);
    } else {
        $table_w_details = '';
        $all_resources_with_tx_git_diff = array();
    }
}

$num_of_resources_w_difference = count($all_resources_with_tx_git_diff);

// preparing a html table represantation of git/tx difference in number of untranslated strings
$table_difference = '';
$num_for_switch_table_to_list = 15;
$table_num_diff = FALSE;
if (0 < $num_of_resources_w_difference && $num_for_switch_table_to_list > $num_of_resources_w_difference) {
    $table_num_diff = TRUE;
    // preparing a table represantation of Tx/git differences
    $i = 0;
    $table_rows     = array();
    $table_rows[]   = "<table>" . PHP_EOL;
    $table_rows[]   = "<thead>" . PHP_EOL;
    $first_row_pass = TRUE;
    $col_repeat = 8;
    foreach ($tx_git_difference as $one_language => $one_language_array) {
        $j   = 0;
        $row = array();
        $first_col_pass = TRUE;
        if ($first_row_pass || 0 == $i % 12) {
            $array_chunks = array_chunk($all_resources_with_tx_git_diff, $col_repeat, TRUE);
            foreach ($array_chunks as $array_chunk) {
                $row = array_merge($row, array('&nbsp;'), $array_chunk);
            }
            $table_rows[] = "<tr class=\"add\"><th>" . implode("</th><th>", $row) . "</th></tr>" . PHP_EOL; // add header row
            if ($first_row_pass) {
                $table_rows[] = "</thead>" . PHP_EOL;
                $table_rows[] = "<tbody>" . PHP_EOL;
                $first_row_pass = FALSE;
            }
        }

        $row = array();
        foreach ($all_resources_with_tx_git_diff as $resource_with_tx_git_diff) {
                if ($first_col_pass || 0 == $j % $col_repeat) { // left cell
                    $language_name = get_language_name($one_language);
                    $row[] = "<div class=\"add\"><span class=\"bold\">$language_name</span> - $one_language</div>";
                    $first_col_pass = FALSE;
                }
                if (array_key_exists($resource_with_tx_git_diff, $one_language_array)) {
                    $stat_data = array();
                    $stat_data['num_of_all'] = $one_language_array[$resource_with_tx_git_diff]['tx_num_of_all_strings'];
                    $stat_data['tx_untran']  = $one_language_array[$resource_with_tx_git_diff]['tx_untranslated'];
                    $stat_data['git_untran'] = $one_language_array[$resource_with_tx_git_diff]['git_untranslated'];
                    $stat_data['git_path']   = $one_language_array[$resource_with_tx_git_diff]['webgit_path'];
                    $stat_data['pot_name']   = $one_language_array[$resource_with_tx_git_diff]['pot_name'];

                    $cell  = "<span class=\"stat\">";
                    $cell .= build_links($resource_with_tx_git_diff, $one_language, $resource_type, $stat_data);
                    $cell .= "</span>";
                    $row[] = $cell;
                } else {
                    $row[] = '&nbsp;'; // there is no differences
                }
                $j++;
        }
        $table_rows[] = "<tr><td class=\"add\">" . implode("</td><td>", $row) . "</td></tr>" . PHP_EOL;
        $i++;
    }
    $table_rows[] = "</tbody>" . PHP_EOL;
    $table_rows[] = "</table>" . PHP_EOL;
    $table_difference = implode($table_rows);
}

// preparing a html list represantation of git/tx difference in number of untranslated strings, one by language other by resources
$list_of_lang_diff     = '';
$list_of_resource_diff = '';
$list_num_diff = FALSE;
if (0 < $num_of_resources_w_difference && !$details_wanted && !$table_num_diff) {
    $list_num_diff = TRUE;
    // preparing a list represantation of Tx/git differences by language
    $list_of_lang_diff .= '<ul>' . PHP_EOL;
    foreach ($tx_git_difference as $one_language => $one_language_array) {
        $language_name = get_language_name($one_language);
        $list_of_lang_diff .= "<li><span class=\"bold\">$language_name</span> - $one_language: " . PHP_EOL;
        $one_language_resources = array_keys($one_language_array);
        $miss_first = TRUE;
        foreach ($one_language_resources as $one_language_resource) {
            $stat_data = array();
            $stat_data['num_of_all'] = $one_language_array[$one_language_resource]['tx_num_of_all_strings'];
            $stat_data['tx_untran']  = $one_language_array[$one_language_resource]['tx_untranslated'];
            $stat_data['git_untran'] = $one_language_array[$one_language_resource]['git_untranslated'];
            $stat_data['git_path']   = $one_language_array[$one_language_resource]['webgit_path'];
            $stat_data['pot_name']   = $one_language_array[$one_language_resource]['pot_name'];

            $list_of_lang_diff .= ($miss_first ? '' :', ');
            $list_of_lang_diff .= "<span class=\"italic\">$one_language_resource</span> <span class=\"stat\">(";
            $list_of_lang_diff .= build_links($one_language_resource, $one_language, $resource_type, $stat_data);
            $list_of_lang_diff .= ')</span>';
            $miss_first = FALSE;
        }
        $list_of_lang_diff .= '</li>' . PHP_EOL;
    }
    $list_of_lang_diff .= '</ul>' . PHP_EOL;


    // preparing a list represantation of Tx/git differences by resources
    $list_of_resource_diff .= '<ul>' . PHP_EOL;
    foreach ($all_resources_with_tx_git_diff as $resource_with_tx_git_diff) {
        $list_of_resource_diff .= '<li><span class="bold">' . $resource_with_tx_git_diff .'</span>: ' . PHP_EOL;
        $miss_first = TRUE;
        foreach ($tx_git_difference as $one_language => $one_language_array) {
            if (isset($one_language_array[$resource_with_tx_git_diff])) {
                $stat_data = array();
                $stat_data['num_of_all'] = $one_language_array[$resource_with_tx_git_diff]['tx_num_of_all_strings'];
                $stat_data['tx_untran']  = $one_language_array[$resource_with_tx_git_diff]['tx_untranslated'];
                $stat_data['git_untran'] = $one_language_array[$resource_with_tx_git_diff]['git_untranslated'];
                $stat_data['git_path']   = $one_language_array[$resource_with_tx_git_diff]['webgit_path'];
                $stat_data['pot_name']   = $one_language_array[$resource_with_tx_git_diff]['pot_name'];

                $list_of_resource_diff .= ($miss_first ? '' :', ');
                $language_name = get_language_name($one_language);
                $list_of_resource_diff .= "<span class=\"italic\">$language_name</span> - $one_language <span class=\"stat\">(";
                $list_of_resource_diff .= build_links($resource_with_tx_git_diff, $one_language, $resource_type, $stat_data);
                $list_of_resource_diff .= ')</span>';
                $miss_first = FALSE;
            }
        }
        $list_of_resource_diff .= '</li>' . PHP_EOL;
    }