diff options
author | filip <filip.komar@gmail.com> | 2014-11-30 16:27:34 +0100 |
---|---|---|
committer | filip <filip.komar@gmail.com> | 2014-11-30 16:27:34 +0100 |
commit | 070c7f127bc814ad6123df4d643df2e50b907886 (patch) | |
tree | 58f26f3b493655dcbd7c0c1e3e166a3d4fc5b218 /langs/report_test.php | |
parent | de66e8b545d769161bbf41e518ccd5b60172b985 (diff) | |
download | www-070c7f127bc814ad6123df4d643df2e50b907886.tar www-070c7f127bc814ad6123df4d643df2e50b907886.tar.gz www-070c7f127bc814ad6123df4d643df2e50b907886.tar.bz2 www-070c7f127bc814ad6123df4d643df2e50b907886.tar.xz www-070c7f127bc814ad6123df4d643df2e50b907886.zip |
First push of report about differences between Transifex and our git repository
Diffstat (limited to 'langs/report_test.php')
-rw-r--r-- | langs/report_test.php | 105 |
1 files changed, 8 insertions, 97 deletions
diff --git a/langs/report_test.php b/langs/report_test.php index 17adbc52e..84bcb1e8c 100644 --- a/langs/report_test.php +++ b/langs/report_test.php @@ -57,23 +57,6 @@ } $times[] = time_debug('start_time'); - /* - * from http://www.php.net/manual/en/function.array-search.php#91365 - * - * copyright (c) the PHP Documentation - * covered by the Creative Commons Attribution 3.0 License (http://creativecommons.org/licenses/by/3.0/legalcode) - */ - function recursive_array_search($needle, $haystack) - { - foreach ($haystack as $key => $value) { - $current_key = $key; - if ($needle === $value OR (is_array($value) && recursive_array_search($needle, $value) !== FALSE)) { - return $current_key; - } - } - return FALSE; - } - include 'lib.php'; $one_language = isset($_GET['l']) ? strip_tags(trim($_GET['l'])) : NULL; $one_resource = isset($_GET['r']) ? strip_tags(trim($_GET['r'])) : NULL; @@ -236,83 +219,10 @@ } } - $total_num_of_strings = 0; // total of all source strings - $language_summary = array(); - $resource_summary = array(); - foreach ($report as $resource_data) { - if ($resource_data['language'] == 'en') { - $total_num_of_strings += $resource_data['num_of_all_strings']; - } - // don't add if there is a need to store languages only for one resource - if(!$all_languages_only_one_resource || $resource_data['resource_filename'] == $one_resource) { - $key_exists = recursive_array_search($resource_data['language'], $language_summary); // is language already in the $language_summary array? - if($resource_data['resource_filename'] == $one_resource) { - $temp_var[0]['language'] = $resource_data['language']; - $temp_var[0]['num_of_all_strings'] = $resource_data['num_of_all_strings']; - $temp_var[0]['num_of_fuzzy_or_missing_strings'] = $resource_data['num_of_fuzzy_or_missing_strings']; - $temp_var[0]['num_of_untranslated_strings'] = $resource_data['num_of_untranslated_strings']; - $temp_var[0]['references'] = $resource_data['references']; - $language_summary[] = $temp_var[0]; - unset($temp_var[0]); // clear var - } else { - if ($key_exists !== FALSE) { - $language_summary[$key_exists]['num_of_all_strings'] += $resource_data['num_of_all_strings']; - $language_summary[$key_exists]['num_of_fuzzy_or_missing_strings'] += $resource_data['num_of_fuzzy_or_missing_strings']; - $language_summary[$key_exists]['num_of_untranslated_strings'] += $resource_data['num_of_untranslated_strings']; - } else { - if($key_exists === FALSE) { - $key_exists = count($language_summary); - } - $language_summary[$key_exists]['language'] = $resource_data['language']; - $language_summary[$key_exists]['num_of_all_strings'] = $resource_data['num_of_all_strings']; - $language_summary[$key_exists]['num_of_fuzzy_or_missing_strings'] = $resource_data['num_of_fuzzy_or_missing_strings']; - $language_summary[$key_exists]['num_of_untranslated_strings'] = $resource_data['num_of_untranslated_strings']; - $language_summary[$key_exists]['references'] = $resource_data['references']; - } - } - } - - // don't add if there is a need to store resources only for one language - if(!$one_language_all_resources || ($resource_data['language'] == $one_language || $resource_data['language'] == 'en')) { - $key_exists = recursive_array_search($resource_data['resource_filename'], $resource_summary); // is resource already in the $resource_summary array? - if($resource_data['language'] == 'en') { - $temp_var[0]['resource_filename'] = $resource_data['resource_filename']; - $temp_var[0]['num_of_all_strings'] = $resource_data['num_of_all_strings']; - $temp_var[0]['num_of_fuzzy_or_missing_strings'] = $resource_data['num_of_fuzzy_or_missing_strings']; - $temp_var[0]['num_of_untranslated_strings'] = $resource_data['num_of_untranslated_strings']; - $temp_var[0]['references'] = $resource_data['references']; - $resource_summary[] = $temp_var[0]; - unset($temp_var[0]); // clear var - } else { - if($one_language_all_resources) { - if($key_exists === FALSE) { - $key_exists = count($resource_summary); - } - $resource_summary[$key_exists]['num_of_fuzzy_or_missing_strings'] = $resource_data['num_of_fuzzy_or_missing_strings']; - $resource_summary[$key_exists]['num_of_untranslated_strings'] = $resource_data['num_of_untranslated_strings']; - $resource_summary[$key_exists]['references'] = $resource_data['references']; - } else if ($key_exists !== FALSE) { - $resource_summary[$key_exists]['num_of_all_strings'] += $resource_data['num_of_all_strings']; - $resource_summary[$key_exists]['num_of_fuzzy_or_missing_strings'] += $resource_data['num_of_fuzzy_or_missing_strings']; - $resource_summary[$key_exists]['num_of_untranslated_strings'] += $resource_data['num_of_untranslated_strings']; - } - } - } - } - foreach ($language_summary as &$single_language_summary) { - $single_language_summary['num_of_translated_strings'] = - $single_language_summary['num_of_all_strings'] - - $single_language_summary['num_of_fuzzy_or_missing_strings'] - - $single_language_summary['num_of_untranslated_strings']; - } - unset($single_language_summary); // foreach by reference - foreach ($resource_summary as &$single_resource_summary) { - $single_resource_summary['num_of_translated_strings'] = - $single_resource_summary['num_of_all_strings'] - - $single_resource_summary['num_of_fuzzy_or_missing_strings'] - - $single_resource_summary['num_of_untranslated_strings']; - } - unset($single_resource_summary); // foreach by reference + $summary = build_language_and_resource_summary($report, $all_languages_only_one_resource, $one_resource, $one_language_all_resources, $one_language); + $total_num_of_strings = $summary['total_num_of_strings']; // total of all source strings + $language_summary = $summary['language_summary']; + $resource_summary = $summary['resource_summary']; if ($one_language_all_resources) { $report_text = '<p>Restore <a href="?l=all" title="see all languages">all languages</a>.</p>'; @@ -320,14 +230,14 @@ $summary_text = 'Summary for each of ' . $num_of_enFiles . ' resources'; $display_array = $resource_summary; $progress = 'References</th><th>Progress'; - $stats_width = '55px'; + $stats_width = '70px'; } else if ($all_languages_only_one_resource) { $report_text = '<p>Restore <a href="?r=all" title="see all resources">all resources</a>.</p>'; $count = 'Together ' . count($otherLangs) . ' languages'; $summary_text = 'Summary for resource: ' . $one_resource; $eng_language = array_shift($language_summary); // shift English for proper sorting $display_array = $language_summary; - $stats_width = '60px'; + $stats_width = '70px'; $progress = 'References</th><th>Progress'; } else { // all languages, all resources $report_text = ''; // <p>Overview of all languages.</p> @@ -336,7 +246,7 @@ $eng_language = array_shift($language_summary); // shift English for proper sorting $display_array = $language_summary; $sum_for_stat = $total_num_of_strings; - $stats_width = '70px'; + $stats_width = '85px'; $references = ''; $progress = 'Progress'; } @@ -364,6 +274,7 @@ foreach ($display_array as $one_member) { $translation_status = 'translated: ' . $one_member['num_of_translated_strings']; $translation_status .= ', fuzzy or missing: ' . $one_member['num_of_fuzzy_or_missing_strings']; + $translation_status .= ', untranslated: ' . $one_member['num_of_untranslated_strings']; if ($one_language_all_resources) { $first_clmn = $one_member['resource_filename']; $link_one = '<a href="?r=' . $first_clmn . '" title="%s">'; |