www.mageia.org report about differences between Transifex and git repositories

Languages translation progress report for web pages is available here.

$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(); $git_resources_list = 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 if (!empty($wanted_resource)) { $enFiles = array($wanted_resource); $report = generating_report(get_other_langs(), $enFiles); } else if (!empty($wanted_language)) { // TODO $enFiles = array_merge(array('../_nav/langs/en.pot'), get_lang_references('*.pot')); $report = generating_report(array($wanted_language), $enFiles, NULL, NULL, $parsed_tx_file_content); } foreach ($enFiles as $git_resource_webpage_name) { $git_webpage_name = resource_name_conversion($git_resource_webpage_name, $wanted_category, TRUE); // TRUE $git_resources_list[] = $git_webpage_name; } } 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']; if (isset($git_resource_details['github_path'])) { // treat resources on GitHub differently $github_raw_path = $git_resource_details['github_path']; $github_raw_html_dump = file_get_contents($github_raw_path); preg_match_all('/\"(\w*)\.po\"/m', $github_raw_html_dump, $language_codes); $git_language_codes = $language_codes[1]; } else { $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([a-z_A-Z0-9@-]+)\.po $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); $new_resources_in_tx = array_diff($git_resources_list, $tx_resources_list); $new_resources_in_git = array_diff($tx_resources_list, $git_resources_list); // preparing text for languages not present yet in git repositories $tx_only_languages_details = ''; if (0 < count($tx_only_languages)) { if (!empty($wanted_language) && !empty($wanted_resource)) { $tx_only_languages_details = "

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 = "

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 = "

Languages with $wanted_resource resource for $resource_type translated over treshold "; } else { $tx_only_languages_details = "

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 git:

'; } // preparing error texts if (0 < count($git_only_languages)) { $error = "Note that some languages (" . implode(", ", $git_only_languages) . ") are present in git"; $errors['git_only_languages'] = "$error but they are below treshold ($tx_lang_completed_treshold %) in Transifex."; } if (0 < count($new_resources_in_tx) && (empty($wanted_resource))) { $error = "Some resources (" . implode(", ", $new_resources_in_tx) . ") are new in Transifex"; $errors['new_resources_in_tx'] = "$error but not present in resources_list.php file so not processed. Please report that."; } if (0 < count($new_resources_in_git) && (empty($wanted_resource))) { $error = "Some resources (" . implode(", ", $new_resources_in_git) . ") are new in git"; $errors['new_resources_in_git'] = "$error but not present in Transifex so not processed. Please report that."; } if (0 < count($git_only_resources)) { $error = "Some resources (" . implode(", ", $git_only_resources) . ") are present only in 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 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[] = "" . PHP_EOL; $table_rows[] = "" . PHP_EOL; $table_rows[] = "" . PHP_EOL; // add header row $table_rows[] = "" . PHP_EOL; $table_rows[] = "" . 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 = ' '; } else { $target_l_str = htmlentities($array_for_compare['target_l'][$i], null, 'UTF-8'); } if (empty($array_for_compare['compared'][$i])) { $compared_str = ' '; } else { $compared_str = htmlentities($array_for_compare['compared'][$i], null, 'UTF-8'); } $row = ""; $row .= ""; $row .= ""; $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[] = "" . PHP_EOL; $table_rows[] = "
Original stringTranslated string from gitAnd translated string from Transifex
$curr_msgid$target_l_str$compared_str
" . 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[] = "" . PHP_EOL; $table_rows[] = "" . PHP_EOL; $first_row_pass = TRUE; $col_repeat = 8; $limit_factor_difference = 10; // difference is bigger than 10% $limit_number_difference = 50; // difference is bigger than 50 strings $clr_red = ' style="background-color: hsl(0, 100%, 85%);"'; $clr_yellow = ' style="background-color: hsl(60, 100%, 85%);"'; $legend = ''; $show_legend = FALSE; 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(' '), $array_chunk); } $table_rows[] = "" . PHP_EOL; // add header row if ($first_row_pass) { $table_rows[] = "" . PHP_EOL; $table_rows[] = "" . 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[] = "
$language_name - $one_language
"; $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']; $completion_difference_number = abs($stat_data['tx_untran'] - $stat_data['git_untran']); $completion_difference_factor = $completion_difference_number / $stat_data['num_of_all']; if (0 == $stat_data['tx_untran'] || 0 == $stat_data['git_untran']) { $cell_style = $clr_red; $show_legend = TRUE; } else if ($limit_factor_difference < 100 * $completion_difference_factor || $limit_number_difference < $completion_difference_number) { // difference is bigger than limits $cell_style = $clr_yellow; $show_legend = TRUE; } else { $cell_style = ''; } $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; $i++; } if (TRUE == $show_legend) { $legend = " (difference is bigger than $limit_factor_difference% or "; $legend .= "$limit_number_difference strings, fully translated in either git or Transifex)"; } $table_rows[] = "" . PHP_EOL; $table_rows[] = "
" . implode("", $row) . "
" . implode("", $row) . "
" . 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 .= '' . PHP_EOL; // preparing a list represantation of Tx/git differences by resources $list_of_resource_diff .= '' . PHP_EOL; } // print links for diferent reports if ('Webpages' != $resource_type) { $links[] = 'website translations'; } if ('Documentation' != $resource_type) { $links[] = 'documentation translations'; } if ('Cauldron' != $resource_type) { // $links[] = 'software translations'; } // list $tx_languages and $tx_cauldron_resources $languages_links = array(); foreach ($tx_languages as $tx_language) { $language_name = get_language_name($tx_language); $languages_links[] = "$tx_language"; } sort($languages_links, SORT_STRING); $num_of_tx_langs = count($languages_links); $languages_link = implode(", ", $languages_links); $resources_links = array(); foreach ($tx_cauldron_resources as $tx_resource_name) { $resources_links[] = "$tx_resource_name"; } $num_of_tx_cauldron_resources = count($resources_links); $resources_link = implode(", ", $resources_links); $reports_links = '

You can also see reports about differences in ' . implode(" or ", $links) . '.

'; $reports_links .= "

For software translations please choose one of it's $num_of_tx_cauldron_resources resources ($resources_link) or "; $reports_links .= "one of a $num_of_tx_langs languages with variants ($languages_link) currently present in Transifex.

"; $reports_links .= '

There is a nice '; $reports_links .= 'wiki page about Transifex and git synchronising.

'; echo $reports_links . PHP_EOL; // print out any errors if (0 < count($errors)) { $error_text = '

There seems to be some errors, warnings or notices during processing this time :(

'; $error_text .= ''; echo $error_text . PHP_EOL; } // print any languages present only in Transifex echo $tx_only_languages_details . PHP_EOL; $diff_desc = "between Transifex and git repository for $resource_type."; if (0 < $num_of_resources_w_difference) { // print any differences between Transifex and git repository if (!empty($wanted_resource) && !empty($wanted_language)) { $diff_title = "

Language $wanted_lang_name below have some differences in resource $wanted_resource $diff_desc

"; } else if (!empty($wanted_resource) && empty($wanted_language)) { $diff_title = "

Languages below have some differences in resource $wanted_resource $diff_desc

"; } else if (empty($wanted_resource) && !empty($wanted_language)) { $diff_title = "

Language $wanted_lang_name below have some differences $diff_desc

"; } else { $diff_title = "

Languages below have some differences in resources $diff_desc

"; } echo $diff_title; echo '

To avoid further alienation and confusion please synchronise them.

'; echo "

They differs on number of untranslated strings in resources$legend:

"; // print a detailed strings difference table if wanted if ($details_wanted) { echo $table_w_details . PHP_EOL; // else print table if there are only a few resources with differences otherwise print a list } else if ($table_num_diff) { echo $table_difference . PHP_EOL; } else if ($list_num_diff) { echo $list_of_lang_diff . PHP_EOL; echo '

Same list but arranged by resources:

'; echo $list_of_resource_diff . PHP_EOL; } } else if (0 == count($tx_only_languages) && !array_key_exists('tx_call', $errors)) { if (!empty($wanted_resource) && !empty($wanted_language)) { $diff_title = "

Congratulations. It seems that resource $wanted_resource in language $wanted_lang_name have no differences $diff_desc

"; } else if (!empty($wanted_resource) && empty($wanted_language)) { $diff_title = "

Congratulations. It seems that resource $wanted_resource has no differences $diff_desc

"; } else if (empty($wanted_resource) && !empty($wanted_language)) { $diff_title = "

Congratulations. It seems that in language $wanted_lang_name there is no resources with differences $diff_desc

"; } else { $diff_title = "

Congratulations. It seems that there is no resources with differences $diff_desc

"; } echo $diff_title; } ?>

Source code for this website is available on git.

' ?>