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

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(); 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 = "

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

'; } // 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[] = "" . 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; 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']; $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++; } $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 one of a $num_of_tx_langs languages ($languages_link).

"; $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 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 our git repository for $resource_type."; if (0 < $num_of_resources_w_difference) { // print any differences between Transifex and our 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:

'; // 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)) { 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.

' ?>