Languages translation progress report for web pages is available here.
'doc_xsl', // Mageia XSL files translation 'tx_name' => 'doc_xsl', 'git_path' => 'http://gitweb.mageia.org/software/i18n/tools/plain/docs/stylesheets/po', ), array( 'pot_name' => 'help', // Mageia Installer Help 'tx_name' => 'doc_installer', 'git_path' => 'http://gitweb.mageia.org/software/i18n/tools/plain/docs/installer', ), array( 'pot_name' => 'mcc-help', // Mageia Control Center Help 'tx_name' => 'mcc-help', 'git_path' => 'http://gitweb.mageia.org/software/i18n/tools/plain/docs/mcc-help', ), ); } else if ('Cauldron' == $resource_type) { $git_resources = array( array( 'pot_name' => 'drakconf', // Mageia Control Center 'tx_name' => 'control-center', 'git_path' => 'http://gitweb.mageia.org/software/control-center/plain/po', ), array( 'pot_name' => 'desktop-common-data', 'tx_name' => 'desktop-common-data', 'git_path' => 'http://gitweb.mageia.org/software/desktop/common-data/plain/po', ), array( 'pot_name' => 'drak3d', 'tx_name' => 'drak3d', 'git_path' => 'http://gitweb.mageia.org/software/drak3d/plain/po', ), array( 'pot_name' => 'drakguard', 'tx_name' => 'drakguard', 'git_path' => 'http://gitweb.mageia.org/software/drakguard/plain/po', ), array( 'pot_name' => 'draklive-install', 'tx_name' => 'draklive-install', 'git_path' => 'http://gitweb.mageia.org/software/draklive-install/plain/po', ), array( 'pot_name' => 'drakmenustyle', 'tx_name' => 'drakmenustyle', 'git_path' => 'http://gitweb.mageia.org/software/drakmenustyle/plain/po', ), array( 'pot_name' => 'drakpxelinux', 'tx_name' => 'drakpxelinux', 'git_path' => 'http://gitweb.mageia.org/software/drakpxelinux/plain/po', ), array( 'pot_name' => 'drakwizard', 'tx_name' => 'drakwizard', 'git_path' => 'http://gitweb.mageia.org/software/drakwizard/plain/po', ), array( 'pot_name' => 'drakx-kbd-mouse-x11', 'tx_name' => 'drakx-kbd-mouse-x11', 'git_path' => 'http://gitweb.mageia.org/software/drakx-kbd-mouse-x11/plain/po', ), array( 'pot_name' => 'drakx-net', 'tx_name' => 'drakx-net', 'git_path' => 'http://gitweb.mageia.org/software/drakx-net/plain/po', ), array( 'pot_name' => 'DrakX', 'tx_name' => 'drakx_install', 'git_path' => 'http://gitweb.mageia.org/software/drakx/plain/perl-install/install/share/po', ), array( 'pot_name' => 'libDrakX', 'tx_name' => 'drakx_share', 'git_path' => 'http://gitweb.mageia.org/software/drakx/plain/perl-install/share/po', ), array( 'pot_name' => 'libDrakX-standalone', 'tx_name' => 'drakx_standalone', 'git_path' => 'http://gitweb.mageia.org/software/drakx/plain/perl-install/standalone/po', ), array( 'pot_name' => 'indexhtml', 'tx_name' => 'indexhtml', 'git_path' => 'http://gitweb.mageia.org/software/indexhtml/plain/po', ), array( 'pot_name' => 'kde4-splash-mga', 'tx_name' => 'kde4-splash-mga', 'git_path' => 'http://gitweb.mageia.org/software/desktop/kde/splash/plain/po', ), array( 'pot_name' => 'bootloader', 'tx_name' => 'mageia-gfxboot-theme', 'git_path' => 'http://gitweb.mageia.org/software/design/bootloader-theme/plain/po', ), array( 'pot_name' => 'mageia-kde-translation', 'tx_name' => 'mageia-kde-translation', 'git_path' => 'http://gitweb.mageia.org/software/i18n/kde/plain/po', ), array( 'pot_name' => 'mageiawelcome', // 'tx_name' => 'Mageia Welcome', 'tx_name' => 'mageia-welcome', 'git_path' => 'http://gitweb.mageia.org/software/mageiawelcome/plain/po', ), array( 'pot_name' => 'mgaonline', 'tx_name' => 'mgaonline', 'git_path' => 'http://gitweb.mageia.org/software/mgaonline/plain/po', ), array( 'pot_name' => 'msec', 'tx_name' => 'msec', 'git_path' => 'http://gitweb.mageia.org/software/msec/plain/po', ), array( 'pot_name' => 'net_monitor', 'tx_name' => 'net_monitor', 'git_path' => 'http://gitweb.mageia.org/software/net_monitor/plain/po', ), array( 'pot_name' => 'rpmdrake', 'tx_name' => 'rpmdrake', 'git_path' => 'http://gitweb.mageia.org/software/rpmdrake/plain/po', ), array( 'pot_name' => 'system-config-printer', 'tx_name' => 'system-config-printer', 'git_path' => 'http://gitweb.mageia.org/software/i18n/system-config-printer/plain/po', ), array( 'pot_name' => 'transfugdrake', 'tx_name' => 'transfugdrake', 'git_path' => 'http://gitweb.mageia.org/software/transfugdrake/plain/po', ), array( 'pot_name' => 'urpmi', 'tx_name' => 'urpmi', 'git_path' => 'http://gitweb.mageia.org/software/rpm/urpmi/plain/po', ), array( 'pot_name' => 'userdrake', 'tx_name' => 'userdrake2', 'git_path' => 'http://gitweb.mageia.org/software/userdrake/plain/po', ), array( 'pot_name' => 'messages', 'tx_name' => 'identity-catdap', 'git_path' => 'http://gitweb.mageia.org/web/identity/plain/lib/CatDap/I18N', ), array( 'pot_name' => 'index', 'tx_name' => 'indexhtml_about', 'git_path' => 'http://gitweb.mageia.org/software/indexhtml/plain/about/po', ), array( 'pot_name' => 'isodumper', 'tx_name' => 'isodumper', // 'git_path' => 'https://github.com/papoteur-mga/isodumper/raw/master/po', 'git_path' => 'http://gitweb.mageia.org/software/isodumper/plain/po', ), array( 'pot_name' => 'mageiaSync_en.ts', 'tx_name' => 'mageiasync', 'git_path' => 'http://gitweb.mageia.org/qa/MageiaSync/plain/translations/', ), array( 'pot_name' => 'manatools', 'tx_name' => 'manatools', 'git_path' => 'http://gitweb.mageia.org/software/manatools/plain/po', ), ); } /** * Transifex API implementation in php detailed on http://docs.transifex.com/developer/api/projects * * Returns $tx_result_array from Transifex request * * @param string $tx_request request * @param string $project default project * * @return array */ function tx_call($tx_request, $project = 'project/mageia/') { global $errors; $tx_url_prefix = "www.transifex.com/api/2/"; $tx_url = $tx_url_prefix . $project . $tx_request; $user = "filip_mageia"; $pass = "report"; $tx_result = @file_get_contents("https://$user:$pass@$tx_url"); $tx_result_array = json_decode($tx_result, TRUE); $json_last_error = json_last_error(); if (JSON_ERROR_NONE !== $json_last_error) { $error = "There was an error during API call to Transifex $tx_request ($json_last_error)."; $errors['tx_json_error'] = "$error Please reload the page later and report this on mailing list if it persist."; $tx_result_array = array(); } else if (FALSE === $tx_result) { $error = "API call to Transifex $tx_request failed."; $errors['tx_call'] = "$error Please reload the page later and report this on mailing list if it persist."; $tx_result_array = array(); } return $tx_result_array; } /** * Convert git resource name to Transifex one or reverse * * @param string $resource_name like 'about/constitution' (git name) * @param string $category like 'Webpages', 'Cauldron' or 'Documentation' * @param boolean $tx_to_git_name_conversion direction of conversion * * @return string $resource_name like 'page-about-constitution' (tx name) */ function resource_name_conversion($resource_name, $category = '', $tx_to_git_name_conversion = FALSE) { $tx_names = array('/', 'mageia-welcome', 'identity-catdap'); $git_names = array('-', 'Mageia%20Welcome', 'Identity%20(CatDap)'); if ($tx_to_git_name_conversion) { $resource_name = str_replace($tx_names, $git_names, $resource_name); } else { $resource_name = str_replace($git_names, $tx_names, $resource_name); } if ('Webpages' == $category) { if ($tx_to_git_name_conversion) { $resource_name = str_replace('page-', '', $resource_name); } else { $resource_name = 'page-' . $resource_name; } } return $resource_name; } /** * Build Transifex and git links with numbers of untranslated strings * * Returns text string * * @param string $git_resource_name like 'about/constitution' * @param string $language_code like 'sl' * @param string $resource_type like 'Webpages' * @param array $stat_data with numbers of untranslated strings * * @return string */ function build_links($git_resource_name, $language_code, $resource_type, $stat_data) { $tx_resource_name = resource_name_conversion($git_resource_name); $locale_name = locale_underscore_to_hyphen($language_code); if ('Webpages' == $resource_type) { if ('nav' == $git_resource_name) { $git_link = sprintf('http://gitweb.mageia.org/web/nav/tree/langs/%s.po', $locale_name); } else { $git_link = sprintf('http://gitweb.mageia.org/web/www/tree/langs/%s/%s.po', $locale_name, $git_resource_name); } } else { // fixing exceptions as there is a different naming convention between Tx and git for some lanuages: if ('system-config-printer' == $git_resource_name && 'sr@latin' == $language_code) { $lang_code = 'sr@latin'; } else if ('identity-catdap' == $git_resource_name && 'en_GB' == $language_code) { $lang_code = 'en_gb'; } else { $tx_array = array('sr@latin', 'uz@Cyrl'); $git_array = array('sr@Latn', 'uz@cyrillic'); $lang_code = str_replace($tx_array, $git_array, $language_code); } // treat TS files differently if (false !== strpos($stat_data['pot_name'], '_en.ts')) { $partial_git_resource_name = substr($stat_data['pot_name'], 0, -6); // cuts '_en.ts' $git_link = sprintf('%s%s_%s.ts', $stat_data['git_path'], $partial_git_resource_name, $lang_code); // mageiaSync_sl.ts } else { $git_link = sprintf('%s/%s.po', $stat_data['git_path'], $lang_code); } } $links_and_num = build_transifex_link($language_code, 'Tx', $resource_type, $tx_resource_name) . ": "; $links_and_num .= $stat_data['tx_untran']; $links_and_num .= (0 == $stat_data['tx_untran'] ? ' - full' : ''); $links_and_num .= ', git: '; $links_and_num .= $stat_data['git_untran']; $links_and_num .= ($stat_data['num_of_all'] == $stat_data['git_untran'] ? ' - empty' : ''); return $links_and_num; } /** * Build customized Transifex link * * @param string $tx_language_code like 'pt_BR' * @param string $link_name is the visible link name * @param string $tx_category like 'Webpages' * @param string $tx_resource_name like 'page-4' * * @return string customized Transifex link */ function build_transifex_link($tx_language_code, $link_name = NULL, $tx_category = NULL, $tx_resource_name = NULL) { // Transifex cripled direct link access in a new version in a way that limiting // the result by the category or resource name is no longer possible // $prefix = ""; if(is_null($link_name)) { $transifex_url .= $tx_language_code; } else { $transifex_url .= $link_name; } $transifex_url .= ""; return $transifex_url; } /** * Generating report about git resources statistics * * @param array $language_codes list * @param array $resource_names list * @param string $path to the git, otherwise NULL * * @return array */ function generating_report($language_codes, $resource_names, $path = NULL, $pot_name = NULL) { $report = array(); foreach ($resource_names as $f) { $source_strings = NULL; foreach ($language_codes as $l) { $references = ''; if (is_null($pot_name)) { $resource = _extract_resource($f); } else { $resource = $pot_name; } $langF = _po_file_switch($f, $l); if (strstr($f, '../_nav/langs/en.') !== FALSE) { $langF = '../_nav/langs/' . $l . '.po' . (($l == 'en') ? 't' : ''); } if (!is_null($path) || file_exists($langF)) { // treat TS files differently if (false !== strpos($pot_name, '_en.ts')) { $partial_pot_name = substr($pot_name, 0, -6); // cuts '_en.ts' from mageiaSync_en.ts $stat = _ts_diff($l, $partial_pot_name, $source_strings, $path); } else { $stat = _po_diff($l, $resource, $source_strings, $path); } $num_of_fuzzy_or_missing = count($stat['fuzzy_or_missing']); } else { // file $langF doesn't exists in 'Webpages' $resource_type $stat = _po_diff('en', $resource, $source_strings); $num_of_fuzzy_or_missing = 0; } $num_of_untranslated = count($stat['notrans']); $source_strings = $stat['source_strings']; // unify resource names, navigation is a special exception $resource_name = str_replace(array('../_nav/langs/en', 'en/', '.pot'), array('nav', '', ''), $f); // fixing exceptions as there is a different naming convention between Tx and git for some lanuages: if ('system-config-printer' == $resource_name && 'sr@latin' == $l) { $web_language_code = 'sr@latin'; } else if ('identity-catdap' == $resource_name && 'en_gb' == $l) { $web_language_code = 'en_GB'; } else { $git_array = array('sr@Latn', 'uz@cyrillic'); $tx_array = array('sr@latin', 'uz@Cyrl'); // create pt_BR from pt-br and alike to unify languages $web_language_code = locale_hyphen_underscore($l, true); $web_language_code = str_replace($git_array, $tx_array, $web_language_code); } $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, 'webgit_path' => $path, 'pot_name' => $pot_name, ); } } return $report; } /** * Returns native language name from Mageia web site if exists otherwise English name from Transifex * * @param string $language_code for language * * @return string */ function get_language_name($language_code) { global $langs; static $tx_languages_details = NULL; $web_language_code = locale_underscore_to_hyphen($language_code); if (array_key_exists($web_language_code, $langs)) { $language_name = $langs[$web_language_code]; } else { if (is_null($tx_languages_details)) { $tx_languages_details = tx_call("languages", ''); } // is language code in the $tx_languages_details array? $key_exists = recursive_array_search($language_code, $tx_languages_details); if ($key_exists !== FALSE) { $language_name = $tx_languages_details[$key_exists]['name']; } else { $language_name = $language_code; } } return $language_name; } // 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(); $tx_cauldron_resources = array(); $tx_stat_for_resource = array(); foreach ($tx_resources as $one_resource) { $tx_resource_name = $one_resource['slug']; $category = $one_resource['categories'][0]; if ('Cauldron' == $category) { $tx_cauldron_resources[] = $tx_resource_name; } // limit resource type only on one if ($category == $resource_type) { if (empty($wanted_resource) || $tx_resource_name == $wanted_resource) { // add statistic if (empty($wanted_language)) { $tx_stat_for_resource = tx_call("resource/$tx_resource_name/stats"); } else { $tx_stat_for_resource[$wanted_language] = tx_call("resource/$tx_resource_name/stats/$wanted_language"); } $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[$tx_resource_name] = $one_resource; } } } $tx_languages = array(); if (empty($wanted_language)) { foreach ($tx_stat_for_resource as $tx_resource_language => $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) { $enFiles = array_merge(array('../_nav/langs/en.pot'), get_lang_references('*.pot')); // added navigation file $report = generating_report(get_other_langs(), $enFiles); } 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); $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) { $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 && '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) { $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']; $git_resource_path = $git_resource_info['webgit_path']; $git_resource_pot_name = $git_resource_info['pot_name']; // 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; $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; } // 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 = "" . implode(" | ", $row) . " |
---|---|
" . implode(" | ", $row) . " |
You can also see reports about differences in ' . implode(" or ", $links) . '.
'; $reports_links .= "For software translations please choose language ($languages_link) or resource ($resources_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 = 'To avoid further alienation and confusion please synchronise them.
'; echo 'They differs on number of untranslated strings in resources:
'; // print table if there are only a few resources with differences otherwise print a list if ($table_num_diff) { echo $table_difference . PHP_EOL; } else if ($list_num_diff) { echo $list_of_lang_diff . PHP_EOL; echo 'Source code for this website is available on git.