From 6c86075b820fd5c95c3470fee99b96a41d15ba3c Mon Sep 17 00:00:00 2001 From: filip Date: Sun, 28 Dec 2014 18:42:05 +0100 Subject: speed test for differences between Tx and our git report of Cauldron resources --- langs/report_tx_git.php | 246 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 211 insertions(+), 35 deletions(-) (limited to 'langs/report_tx_git.php') diff --git a/langs/report_tx_git.php b/langs/report_tx_git.php index a305142f3..f6f31a526 100644 --- a/langs/report_tx_git.php +++ b/langs/report_tx_git.php @@ -37,7 +37,7 @@ include 'lib.php'; $errors = array(); // stored for error management ;) $c = (isset($_GET['c']) ? strip_tags(trim($_GET['c'])) : ''); -if (in_array($c, array('Webpages', 'Documentation'/*, 'Cauldron'*/))) { +if (in_array($c, array('Webpages', 'Documentation', 'Cauldron'))) { $resource_type = $c; // filter only valid resource types } else { $resource_type = 'Webpages'; // default @@ -56,6 +56,145 @@ if ('Documentation' == $resource_type) { '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' => 'copyiso2usb', + 'tx_name' => 'copyiso2usb', + 'git_path' => 'http://gitweb.mageia.org/software/copyiso2usb/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', + ), + ); // identity-catdap, indexhtml_about, isodumper } @@ -84,11 +223,10 @@ function tx_call($tx_request, $project = 'project/mageia/') $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_call'] = "$error Please reload the page or report this on mailing list."; + $errors['tx_json_error'] = "$error Please reload the page and report this on mailing list if it persist."; $tx_result_array = array(); - } - if (FALSE === $tx_result) { - $errors['tx_call'] = "API call to Transifex $tx_request failed. Please reload the page or report this on mailing list."; + } else if (FALSE === $tx_result) { + $errors['tx_call'] = "API call to Transifex $tx_request failed. Please reload the page and report this on mailing list if it persist."; $tx_result_array = array(); } return $tx_result_array; @@ -108,14 +246,16 @@ function tx_call($tx_request, $project = 'project/mageia/') */ function build_links($git_resource_name, $language_code, $resource_type, $stat_data) { - $tx_resource_name = str_replace('/', '-', $git_resource_name); + $tx_resource_name = str_replace(array('/', 'mageia-welcome'), array('-', 'Mageia%20Welcome'), $git_resource_name); $locale_name = locale_underscore_to_hyphen($language_code); - if ('nav' == $git_resource_name) { - $git_link = sprintf('http://gitweb.mageia.org/web/nav/tree/langs/%s.po', $locale_name); - } else if ('Documentation' == $resource_type) { - $git_link = sprintf('%s/%s.po', $stat_data['git_path'], $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 { - $git_link = sprintf('http://gitweb.mageia.org/web/www/tree/langs/%s/%s.po', $locale_name, $git_resource_name); + $git_link = sprintf('%s/%s.po', $stat_data['git_path'], $language_code); } $links_and_num = "Tx: "; @@ -179,15 +319,40 @@ function generating_report($language_codes, $resource_names, $path = NULL, $pot_ 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", ''); + } + $key_exists = recursive_array_search($language_code, $tx_languages_details); // is language code in the $tx_languages_details array? + if ($key_exists !== FALSE) { + $language_name = $tx_languages_details[$key_exists]['name']; + } else { + $language_name = $language_code; + } + } + return $language_name; +} -$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 @@ -206,7 +371,7 @@ $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 if ('Documentation' == $resource_type) { +} else { foreach ($git_resources as $git_resource_details) { $git_path = $git_resource_details['git_path']; $tx_name = $git_resource_details['tx_name']; @@ -229,6 +394,7 @@ $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']; @@ -270,13 +436,13 @@ foreach ($tx_resources_info as $tx_resource_info) { $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; } - // this bellow should normaly only happen inside of a tx sync window so remember it + // it seems like a parse error if (0 == $git_resource_num_of_all_strings) { - $parse_error = "It seems that parsing of $git_resource_name.po file failed in $git_resource_language language."; - $errors['po_file_parse'] = $parse_error; // [$git_resource_name][$git_resource_language] + $parse_errors[$git_resource_name][] = $git_resource_language; + // this bellow 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 (!in_array($git_resource_name, $nonequal_num_of_all_strings)) { - $nonequal_num_of_all_strings[] = $git_resource_name; + if (!array_key_exists($git_resource_name, $nonequal_num_of_all_strings)) { + $nonequal_num_of_all_strings[$git_resource_name] = "$git_resource_name git:$git_resource_num_of_all_strings/tx:$tx_resource_all_strings_in_lang"; } } } @@ -310,10 +476,10 @@ 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: