aboutsummaryrefslogtreecommitdiffstats
path: root/langs/report_tx_git.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2014-12-28 18:42:05 +0100
committerfilip <filip.komar@gmail.com>2014-12-28 18:42:05 +0100
commit6c86075b820fd5c95c3470fee99b96a41d15ba3c (patch)
tree787e4c8137e078dc20af48a1567d0a4c4984396e /langs/report_tx_git.php
parent0539f811690650ab27a9a546e8e7806ecd2207c2 (diff)
downloadwww-6c86075b820fd5c95c3470fee99b96a41d15ba3c.tar
www-6c86075b820fd5c95c3470fee99b96a41d15ba3c.tar.gz
www-6c86075b820fd5c95c3470fee99b96a41d15ba3c.tar.bz2
www-6c86075b820fd5c95c3470fee99b96a41d15ba3c.tar.xz
www-6c86075b820fd5c95c3470fee99b96a41d15ba3c.zip
speed test for differences between Tx and our git report of Cauldron resources
Diffstat (limited to 'langs/report_tx_git.php')
-rw-r--r--langs/report_tx_git.php246
1 files changed, 211 insertions, 35 deletions
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 = "<a href=\"http://www.transifex.com/organization/MageiaLinux/dashboard/all_resources/";
$links_and_num .= "$language_code/#1/?s=$tx_resource_name&amp;c=$resource_type\">Tx</a>: ";
@@ -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 = "<h3>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:</h3><ul>";
foreach ($tx_only_languages as $tx_only_language) {
- $tx_language_details = tx_call("language/$tx_only_language", '');
- $tx_only_languages_details .= '<li><span class="bold">' . $tx_only_language . '</span>: ';
+ $language_name = get_language_name($tx_only_language);
+ $tx_only_languages_details .= '<li><span class="bold">' . $language_name . '</span>: ';
$tx_only_languages_details .= '<a href="http://www.transifex.com/organization/MageiaLinux/dashboard/all_resources/';
- $tx_only_languages_details .= "$tx_only_language/#1/?c=$resource_type\">" . $tx_language_details['name'] . "</a> (resources over treshold: ";
+ $tx_only_languages_details .= "$tx_only_language/#1/?c=$resource_type\">$tx_only_language</a> (resources over treshold: ";
$resources_above_treshold = array();
foreach ($tx_all_langs_above_treshold[$tx_only_language] as $resource_above_treshold) {
$resources_above_treshold[] = $resource_above_treshold;
@@ -326,7 +492,7 @@ if (0 < count($tx_only_languages)) {
// preparing error texts
if (0 < count($git_only_languages)) {
- $error = "Some languages (" . implode(", ", $git_only_languages) . ") are present in our git";
+ $error = "Note that some languages (" . implode(", ", $git_only_languages) . ") are present in our git";
$errors['git_only_languages'] = "$error but they are bellow treshold ($tx_lang_completed_treshold %) in Transifex.";
}
@@ -340,9 +506,18 @@ if (0 < count($git_only_resources)) {
$errors['git_only_resources'] = "$error but not in Transifex. Please report that.";
}
+if (0 < count($parse_errors)) {
+ $errors = array();
+ foreach ($parse_errors as $single_git_resource_name => $git_resource_languages) {
+ $errors[] = "$single_git_resource_name.po (languages: " . implode(", ", $git_resource_languages) . ")";
+ }
+ $errors['po_file_parse'] = "It seems that parsing of some resources failed: " . implode(", ", $errors) . ".";
+}
+
if (0 < count($nonequal_num_of_all_strings)) {
$error = "Some resources (" . implode(", ", $nonequal_num_of_all_strings) . ") have different number of all strings";
- $errors['nonequal_num_of_all_strings'] = "$error between our git and Transifex. Please report that on the mailing list if it happens several days.";
+ $bug = "Note that there is a <a href=\"https://bugs.mageia.org/show_bug.cgi?id=14899\">bug which influence proper parsing of msec and mageia-kde-translation</a>.";
+ $errors['nonequal_num_of_all_strings'] = "$error between our git and Transifex. Please report that on the mailing list if it happens across several days. $bug";
}
// making a list of resources with Tx/git differences
@@ -383,7 +558,8 @@ if (0 < $num_of_resources_w_difference && $num_for_switch_table_to_list > $num_o
foreach ($all_resources_with_tx_git_diff as $resource_with_tx_git_diff) {
if ($first_col_pass || 0 == $j % $col_repeat) { // left cell
- $row[] = "<div class=\"add\"><span class=\"bold\">" . $langs[locale_underscore_to_hyphen($one_language)] . "</span> - $one_language</div>";
+ $language_name = get_language_name($one_language);
+ $row[] = "<div class=\"add\"><span class=\"bold\">$language_name</span> - $one_language</div>";
$first_col_pass = FALSE;
}
if (array_key_exists($resource_with_tx_git_diff, $one_language_array)) {
@@ -421,8 +597,8 @@ if (0 < $num_of_resources_w_difference) {
// preparing a list represantation of Tx/git differences by language
$list_of_lang_diff .= '<ul>' . PHP_EOL;
foreach ($tx_git_difference as $one_language => $one_language_array) {
- $list_of_lang_diff .= '<li><span class="bold">' . $langs[locale_underscore_to_hyphen($one_language)];
- $list_of_lang_diff .= '</span> - ' . $one_language . ': ' . PHP_EOL;
+ $language_name = get_language_name($one_language);
+ $list_of_lang_diff .= "<li><span class=\"bold\">$language_name</span> - $one_language: " . PHP_EOL;
$one_language_resources = array_keys($one_language_array);
$miss_first = TRUE;
foreach ($one_language_resources as $one_language_resource) {
@@ -457,8 +633,8 @@ if (0 < $num_of_resources_w_difference) {
$stat_data['git_path'] = $one_language_array[$resource_with_tx_git_diff]['webgit_path'];
$list_of_resource_diff .= ($miss_first ? '' :', ');
- $list_of_resource_diff .= '<span class="italic">' . $langs[locale_underscore_to_hyphen($one_language)];
- $list_of_resource_diff .= "</span> - $one_language <span class=\"stat\">(";
+ $language_name = get_language_name($one_language);
+ $list_of_resource_diff .= "<span class=\"italic\">$language_name</span> - $one_language <span class=\"stat\">(";
$list_of_resource_diff .= build_links($resource_with_tx_git_diff, $one_language, $resource_type, $stat_data);
$list_of_resource_diff .= ')</span>';
$miss_first = FALSE;
@@ -479,7 +655,8 @@ if ('Documentation' != $resource_type) {
if ('Cauldron' != $resource_type) {
// $links[] = '<a href="./report_tx_git.php?c=Cauldron">software translations</a>';
}
-$reports_links = '<p>You can also see reports about differences in ' . implode(" or ", $links) . '.</p>';
+$reports_links = '<p>You can also see reports about differences in ' . implode(" or ", $links) . '. And please don\'t forget great ';
+$reports_links .=. '<a href="https://wiki.mageia.org/en/Transifex_and_git_syncing">wiki page about Transifex and git syncing</a>.</p>';
echo $reports_links . PHP_EOL;
// print out any errors
@@ -495,12 +672,11 @@ if (0 < count($errors)) {
// print any languages present only in Transifex
echo $tx_only_languages_details . PHP_EOL;
-// print any differences between Transifex and our git repository
-echo '<h3>Languages bellow have some differences between Transifex and our git repository.</h3>';
-echo '<p>To avoid furter alienation and confusion please synchronise them.</p>';
-echo '<p>They differs on number of untranslated strings in resources:</p>';
-
if (0 < $num_of_resources_w_difference) {
+ // print any differences between Transifex and our git repository
+ echo '<h3>Languages bellow have some differences between Transifex and our git repository.</h3>';
+ echo '<p>To avoid furter alienation and confusion please synchronise them.</p>';
+ echo '<p>They differs on number of untranslated strings in resources:</p>';
// 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;