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 = "Please add them to our git.
" . implode(" | ", $row) . " |
---|---|
" . implode(" | ", $row) . " |
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 'Source code for this website is available on git.