aboutsummaryrefslogtreecommitdiffstats
path: root/langs/report_tx_git.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2015-04-26 19:11:16 +0200
committerfilip <filip.komar@gmail.com>2015-04-26 19:11:16 +0200
commit1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49 (patch)
tree7fa1a8cbd095da07333e95dc60095fae108cc1d2 /langs/report_tx_git.php
parent2903bacdcdde7bf53e849c8cf86cd1c0e6561347 (diff)
downloadwww-1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49.tar
www-1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49.tar.gz
www-1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49.tar.bz2
www-1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49.tar.xz
www-1fb8dd20b4f298dbe1e1f20b7521b8386fb5af49.zip
add capabilities to properly process l10n *.ts files like mageiaSync_en.ts
Diffstat (limited to 'langs/report_tx_git.php')
-rw-r--r--langs/report_tx_git.php40
1 files changed, 34 insertions, 6 deletions
diff --git a/langs/report_tx_git.php b/langs/report_tx_git.php
index 79bfefb87..bbc14234d 100644
--- a/langs/report_tx_git.php
+++ b/langs/report_tx_git.php
@@ -219,6 +219,11 @@ if ('Documentation' == $resource_type) {
// '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/',
+ ),
);
}
@@ -292,7 +297,13 @@ function build_links($git_resource_name, $language_code, $resource_type, $stat_d
$git_array = array('sr@Latn', 'uz@cyrillic');
$lang_code = str_replace($tx_array, $git_array, $language_code);
}
- $git_link = sprintf('%s/%s.po', $stat_data['git_path'], $lang_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'];
@@ -361,7 +372,13 @@ function generating_report($language_codes, $resource_names, $path = NULL, $pot_
$langF = '../_nav/langs/' . $l . '.po' . (($l == 'en') ? 't' : '');
}
if (!is_null($path) || file_exists($langF)) {
- $stat = _po_diff($l, $resource, $source_strings, $path);
+ // 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);
@@ -390,6 +407,7 @@ function generating_report($language_codes, $resource_names, $path = NULL, $pot_
'web_language_code' => $web_language_code,
'num_of_not_fully_trans' => $num_of_not_fully_trans,
'webgit_path' => $path,
+ 'pot_name' => $pot_name,
);
}
}
@@ -481,7 +499,12 @@ if ('Webpages' == $resource_type) {
$errors['file_get_contents_failed'] = "Access to $git_path failed.";
}
// list all po files from links within $raw_html_dump
- preg_match_all("/('>)([a-z_A-Z@-]+)(\.po<)/", $raw_html_dump, $language_codes);
+ 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-Z@-]+)(\.ts<)/", $raw_html_dump, $language_codes);
+ } else {
+ preg_match_all("/('>)([a-z_A-Z@-]+)(\.po<)/", $raw_html_dump, $language_codes);
+ }
$git_language_codes = $language_codes[2];
if (is_null($wanted_language)) {
$report_language_codes = $git_language_codes;
@@ -542,6 +565,7 @@ foreach ($tx_resources_info as $tx_resource_info) {
$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) {
@@ -549,6 +573,7 @@ foreach ($tx_resources_info as $tx_resource_info) {
$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) {
@@ -655,12 +680,12 @@ if (0 < count($git_only_resources)) {
}
if (0 < count($parse_errors)) {
- $errors = array();
+ $errors_in_parsing = array();
foreach ($parse_errors as $single_git_resource_name => $git_resource_languages) {
- $errors[] = "$single_git_resource_name.po (languages: " . implode(", ", $git_resource_languages) . ")";
+ $errors_in_parsing[] = "$single_git_resource_name.po (languages: " . implode(", ", $git_resource_languages) . ")";
}
$reload = "Please reload the page and report this on mailing list if it persist.";
- $errors['po_file_parse'] = "It seems that parsing of some resources failed: " . implode(", ", $errors) . ". $reload";
+ $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)) {
@@ -719,6 +744,7 @@ if (0 < $num_of_resources_w_difference && $num_for_switch_table_to_list > $num_o
$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 = "<span class=\"stat\">";
$cell .= build_links($resource_with_tx_git_diff, $one_language, $resource_type, $stat_data);
@@ -758,6 +784,7 @@ if (0 < $num_of_resources_w_difference) {
$stat_data['tx_untran'] = $one_language_array[$one_language_resource]['tx_untranslated'];
$stat_data['git_untran'] = $one_language_array[$one_language_resource]['git_untranslated'];
$stat_data['git_path'] = $one_language_array[$one_language_resource]['webgit_path'];
+ $stat_data['pot_name'] = $one_language_array[$one_language_resource]['pot_name'];
$list_of_lang_diff .= ($miss_first ? '' :', ');
$list_of_lang_diff .= "<span class=\"italic\">$one_language_resource</span> <span class=\"stat\">(";
@@ -782,6 +809,7 @@ if (0 < $num_of_resources_w_difference) {
$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'];
$list_of_resource_diff .= ($miss_first ? '' :', ');
$language_name = get_language_name($one_language);