From 070c7f127bc814ad6123df4d643df2e50b907886 Mon Sep 17 00:00:00 2001 From: filip Date: Sun, 30 Nov 2014 16:27:34 +0100 Subject: First push of report about differences between Transifex and our git repository --- langs.inc.php | 20 +++ langs/lib.php | 104 ++++++++++++ langs/report.php | 104 ++---------- langs/report_test.php | 105 +----------- langs/report_tx_git.php | 443 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 585 insertions(+), 191 deletions(-) create mode 100644 langs/report_tx_git.php diff --git a/langs.inc.php b/langs.inc.php index 5e9dceab5..4826b4ecf 100644 --- a/langs.inc.php +++ b/langs.inc.php @@ -117,6 +117,26 @@ function locale_hyphen_underscore($locale, $version_of_locale_uppercase = false) } +/** + * Create string pt-br from string pt_br or pt_BR and alike but leave the rest as is + * Return string. + * Do not exit the process. + * + * @param string $locale which we want to change + * + * @return string +*/ +function locale_underscore_to_hyphen($locale) +{ + preg_match("/(..)(_)(..)/", $locale, $parsed_locale); + if(isset($parsed_locale[3])) { + return $parsed_locale[1] . '-' . strtolower($parsed_locale[3]); + } else { + return $locale; + } +} + + /** */ function show_langs($langs) diff --git a/langs/lib.php b/langs/lib.php index b238cdd4c..03520e317 100644 --- a/langs/lib.php +++ b/langs/lib.php @@ -269,3 +269,107 @@ function aproximate_number_of_untranslated_constitution_lines($app_root, $lang, 'aproximate_number_of_untranslated_lines' => $aproximate_number_of_untranslated_lines, ); } + +function build_language_and_resource_summary($report, $all_languages_only_one_resource = FALSE, $one_resource = NULL, $one_language_all_resources = FALSE, $one_language = NULL) +{ + $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 + + return array( + 'total_num_of_strings' => $total_num_of_strings, // total of all source strings + 'language_summary' => $language_summary, + 'resource_summary' => $resource_summary, + ); +} + +/** + * 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; +} diff --git a/langs/report.php b/langs/report.php index fcd574d8a..0b7a57996 100644 --- a/langs/report.php +++ b/langs/report.php @@ -35,26 +35,12 @@
+ +

Report about differences between Transifex and our git repository is available here.

+ $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; @@ -217,83 +203,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 = '

Restore all languages.

'; @@ -410,6 +323,9 @@
S; ?> +

Source code for this website is + available on git.

+
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 = '

Restore all languages.

'; @@ -320,14 +230,14 @@ $summary_text = 'Summary for each of ' . $num_of_enFiles . ' resources'; $display_array = $resource_summary; $progress = 'ReferencesProgress'; - $stats_width = '55px'; + $stats_width = '70px'; } else if ($all_languages_only_one_resource) { $report_text = '

Restore all resources.

'; $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 = 'ReferencesProgress'; } else { // all languages, all resources $report_text = ''; //

Overview of all languages.

@@ -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 = ''; diff --git a/langs/report_tx_git.php b/langs/report_tx_git.php new file mode 100644 index 000000000..29aee5eae --- /dev/null +++ b/langs/report_tx_git.php @@ -0,0 +1,443 @@ + + + + + + www.mageia.org report about differences between Transifex and our git repository + + + +
+

www.mageia.org report about differences between Transifex and our git repository

+ +
+
+ +

Progress report is available here.

+ +Tx: "; + $links_and_num .= $stat_data['tx_untran']; + $links_and_num .= ', git: '; + $links_and_num .= $stat_data['git_untran']; + + return $links_and_num; +} + + +$tx_resources = array(); +// get resources data from TX +$tx_resources = tx_call("resources"); + +// create separate array ($tx_resources_info) and add statistics to it from TX +$tx_resources_info = array(); +foreach ($tx_resources as $one_resource) { + $one_tx_resource_info = array(); + $tx_resource_name = $one_resource['slug']; + $category = $one_resource['categories'][0]; + // limit resource type only on one + if ($category == $resource_type) { + // add statistic + $tx_stat_for_resource = tx_call("resource/$tx_resource_name/stats"); + $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[] = $one_resource; + } +} + +// create array ($report) with statistics from git +$report = array(); +$otherLangs = get_other_langs(); +$enFiles = array_merge(array('../_nav/langs/en.pot'), get_lang_references('*.pot')); // added navigation file +foreach ($otherLangs as $l) { + foreach ($enFiles as $f) { + $references = ''; + $resource = _extract_resource($f); + $langF = _po_file_switch($f, $l); + if (strstr($f, '../_nav/langs/en.') !== FALSE) { + $langF = '../_nav/langs/' . $l . '.po' . (($l == 'en') ? 't' : ''); + } + if (file_exists($langF)) { + $stat = _po_diff($l, $resource); + $num_of_fuzzy_or_missing = count($stat['fuzzy_or_missing']); + $num_of_untranslated = count($stat['notrans']); + } else { // file $langF doesn't exists + $stat = _po_diff('en', $resource); + $num_of_fuzzy_or_missing = 0; + $num_of_untranslated = count($stat['notrans']); + } + // unify resource names, navigation is a special exception + $resource_name = str_replace(array('../_nav/langs/en', 'en/', '.pot'), array('nav', '', ''), $f); + // create pt_BR from pt-br and alike to unify languages + $web_language_code = locale_hyphen_underscore($l, true); + $num_of_not_fully_trans = $num_of_fuzzy_or_missing + $num_of_untranslated; + $report[] = array( + 'num_of_all_strings' => $stat['a'], + 'resource_name' => $resource_name, + 'web_language_code' => $web_language_code, + 'num_of_not_fully_trans' => $num_of_not_fully_trans, + ); + } +} + +// core part: building the data +$tx_lang_completed_treshold = 90; // 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(); +$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) { + $completed = sprintf("%d", $tx_resource_language_stat['completed']); + if (!in_array($tx_resource_language, $tx_all_languages)) { + $tx_all_languages[] = $tx_resource_language; + } + if ($tx_lang_completed_treshold <= $completed) { + if (!in_array($tx_resource_language, $tx_all_langs_above_treshold)) { + $tx_all_langs_above_treshold[] = $tx_resource_language; + } + } + 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) { + + $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']; + + $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']; + + // compare l10n level + if ($tx_resource_untrans_in_lang != $git_resource_untrans_in_lang) { + $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; + } + // this bellow should normaly only happen inside of a tx sync window so remember it + if ($tx_resource_all_strings_in_lang != $git_resource_num_of_all_strings) { + if (!in_array($git_resource_name, $nonequal_num_of_all_strings)) { + $nonequal_num_of_all_strings[] = $git_resource_name; + } + } + } + } + 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); +sort($tx_all_langs_above_treshold); +sort($git_all_languages); +sort($nonequal_num_of_all_strings, SORT_STRING); + +$tx_only_resources = array_diff($tx_all_resource_names, $git_compare_resources); +$git_only_resources = array_diff($git_compare_resources, $tx_all_resource_names); +$tx_only_languages = array_diff($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)) { + $tx_only_languages_details = "

Languages with at least one resource for $resource_type translated over treshold "; + $tx_only_languages_details .= "($tx_lang_completed_treshold %) but not present yet in our git:

"; + $tx_only_languages_details .= '

Please add them to our git.

'; +} + +// preparing error texts +if (0 < count($git_only_languages)) { + $error = "Some languages (" . implode(", ", $git_only_languages) . ") are present in our git"; + $errors['git_only_languages'] .= "$error but they are bellow treshold ($tx_lang_completed_treshold %) in Transifex. Please report that."; +} + +if (0 < count($tx_only_resources)) { + $error = "Some resources (" . implode(", ", $tx_only_resources) . ") are present only in Transifex"; + $errors['tx_only_resources'] .= "$error but not in our git. Please report that."; +} + +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($nonequal_num_of_all_strings)) { + $error = "Some resources (" . implode(", ", $nonequal_num_of_all_strings) . ") have different number of all strings"; + $errors['nonequal_num_of_all_strings'] .= "$error between our git and Transifex. Please report that on the mailing list if it happens several days."; +} + +// making a list of resources with Tx/git differences +ksort($tx_git_difference); +$all_languages_with_tx_git_diff = array(); +$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); +$num_of_resources_w_difference = count($all_resources_with_tx_git_diff); + +$table_difference = ''; +$num_for_switch_table_to_list = 15; +if (0 < $num_of_resources_w_difference && $num_for_switch_table_to_list > $num_of_resources_w_difference) { + // preparing a table represantation of Tx/git differences + $i = 0; + $table_rows = array(); + $table_rows[] = "" . PHP_EOL; + $table_rows[] = "" . PHP_EOL; + $first_row_pass = TRUE; + foreach ($tx_git_difference as $one_language => $one_language_array) { + $j = 0; + $row = array(); + $first_col_pass = TRUE; + if ($first_row_pass || 0 == $i % 10) { + $array_chunks = array_chunk($all_resources_with_tx_git_diff, $col_repeat = 8, TRUE); + foreach ($array_chunks as $array_chunk) { + $row = array_merge($row, array(' '), $array_chunk); + } + $table_rows[] = "" . PHP_EOL; // add header row + $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 + $row[] = "
" . $langs[locale_underscore_to_hyphen($one_language)] . " - $one_language
"; + $first_col_pass = FALSE; + } + if (array_key_exists($resource_with_tx_git_diff, $one_language_array)) { + $stat_data = array(); + $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']; + + $cell = ""; + $cell .= build_links($resource_with_tx_git_diff, $one_language, $resource_type, $stat_data); + $cell .= ""; + $row[] = $cell; + } else { + $row[] = ' '; // there is no differences + } + $j++; + } + $table_rows[] = "" . PHP_EOL; + if ($first_row_pass) { + $table_rows[] = "" . PHP_EOL; + $table_rows[] = "" . PHP_EOL; + $first_row_pass = FALSE; + } + $i++; + } + $table_rows[] = "" . PHP_EOL; + $table_rows[] = "
" . implode("", $row) . "
" . implode("", $row) . "
" . PHP_EOL; + $table_difference = implode($table_rows); +} + +$list_of_lang_diff = ''; +$list_of_resource_diff = ''; +if (0 < $num_of_resources_w_difference) { + // preparing a list represantation of Tx/git differences by language + $list_of_lang_diff .= '' . PHP_EOL; + + + // preparing a list represantation of Tx/git differences by resources + $list_of_resource_diff .= '' . PHP_EOL; +} + +// print out any errors +if (0 < count($errors)) { + $error_text = ''; + echo $error_text . PHP_EOL; +} + +// print any languages present only in Transifex +echo $tx_only_languages_details . PHP_EOL; + +// print any differences between Transifex and our git repository +echo '

Languages bellow have some differences between Transifex and our git repository.

'; +echo '

To avoid furter alienation and confusion please synchronise them.

'; +echo '

They differs on number of untranslated strings in resources:

'; + +if (0 < $num_of_resources_w_difference) { + // print table if there are only a few resources with differences otherwise print a list + if ($num_for_switch_table_to_list > $num_of_resources_w_difference) { + echo $table_difference . PHP_EOL; + } else { + echo $list_of_lang_diff . PHP_EOL; + echo '

Same list but arranged by resources:

'; + echo $list_of_resource_diff . PHP_EOL; + } +} +?> +

Source code for this website is + available on git.

+
+ ' ?> + + \ No newline at end of file -- cgit v1.2.1