aboutsummaryrefslogtreecommitdiffstats
path: root/langs/report.php
diff options
context:
space:
mode:
authorFilip Komar <filip@mageia.org>2014-01-12 21:32:30 +0000
committerFilip Komar <filip@mageia.org>2014-01-12 21:32:30 +0000
commit3a2f4b84559d12dcf2e73fdf97d14337876e069c (patch)
treea80aaaf51292c2ceee45892077f783185765198d /langs/report.php
parent417e1cd2e0fbb4b231391f4b1b53a78ddbd889da (diff)
downloadwww-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar
www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.gz
www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.bz2
www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.tar.xz
www-3a2f4b84559d12dcf2e73fdf97d14337876e069c.zip
l10n report can be limited to only one resource + better management of untranslated lines in constitution
Diffstat (limited to 'langs/report.php')
-rw-r--r--langs/report.php82
1 files changed, 55 insertions, 27 deletions
diff --git a/langs/report.php b/langs/report.php
index 6f8fcbb8a..63cfde1e7 100644
--- a/langs/report.php
+++ b/langs/report.php
@@ -38,14 +38,24 @@
/**
*/
$one_language = isset($_GET['l']) ? strip_tags(trim($_GET['l'])) : null;
+ $one_resource = isset($_GET['r']) ? strip_tags(trim($_GET['r'])) : null;
include 'lib.php';
define('APP_ROOT', realpath(__DIR__ . '/..'));
- $enFiles = get_lang_references();
- // added navigation file
- array_unshift($enFiles, '../_nav/langs/en.lang');
+ $restore_languages = FALSE;
+ $restore_resources = FALSE;
+
+ if (isset($one_resource) && $one_resource != 'all') {
+ $enFiles = array($one_resource);
+ $restore_resources = TRUE;
+ } else {
+ $enFiles = get_lang_references();
+ array_unshift($enFiles, '../_nav/langs/en.lang'); // added navigation file
+ }
+
if (isset($one_language) && $one_language != 'all') {
$otherLangs = array('en', $one_language);
+ $restore_languages = TRUE;
} else {
$otherLangs = get_other_langs();
}
@@ -59,13 +69,15 @@
$diff_link = '<a href="diff.php?s=%s&amp;l=%s" title="see detailed diff">';
$languages = array();
+ $unique_lines_in_eng_constitution = 0;
+ $number_of_unique_lines_in_eng_constitution = 0;
foreach ($otherLangs as $l) {
$stats['en']['files'] += 1;
$stats[$l]['files'] = 0;
$stats[$l]['strings'] = 0;
- if ($l == 'en') {
+ if ($l == 'en' || $restore_languages) {
$link_one_language = '%s';
} else {
$link_one_language = '<a href="?l=' . $l . '" title="see this language only">%s</a>';
@@ -118,14 +130,13 @@
$num_of_duplicated_strings = count($test['dup_str']);
if ($link == 'about/constitution') {
- $dest_constitution = sprintf('%s/%s/%s/%s_%s.md', APP_ROOT, $l, 'about/constitution', 'mageia.org_statutes', $l);
+ $constitution_results = aproximate_number_of_untranslated_constitution_lines(APP_ROOT, $l, $unique_lines_in_eng_constitution);
if ($l == 'en') {
- $strings_en_constitution = count(array_unique(file($dest_constitution)));
- }
- $test['a'] += $strings_en_constitution; // add aproximate number of strings from constitution to translate
- if(!is_readable($dest_constitution) || $l == 'en') {
- $num_of_untranslated_strings += $strings_en_constitution; // add all constitution strings
+ $unique_lines_in_eng_constitution = $constitution_results['unique_lines_in_constitution'];
+ $number_of_unique_lines_in_eng_constitution = count($unique_lines_in_eng_constitution);
}
+ $test['a'] += $number_of_unique_lines_in_eng_constitution; // add aproximate number of lines from constitution to translate
+ $num_of_untranslated_strings += $constitution_results['aproximate_number_of_untranslated_lines'];
}
if ($link == 'about/license') {
require_once('../en/about/license/license.php');
@@ -148,17 +159,17 @@
);
} else if ($link == '2') {
$mga = array(
- 'A' => '2/download_index.php',
- 'B' => '2/for-pc/index.php',
- 'C' => '2/for-server/index.php',
- 'D' => '2/index.php',
+ 'A' => '2/index.php',
+ 'B' => '2/download_index.php',
+ 'C' => '2/for-pc/index.php',
+ 'D' => '2/for-server/index.php',
);
} else if ($link == '3') {
$mga = array(
- 'A' => '3/download_index.php',
- 'B' => 'for-pc/index.php',
- 'C' => 'for-server/index.php',
- 'D' => '3/index.php',
+ 'A' => '3/index.php',
+ 'B' => '3/download_index.php',
+ 'C' => 'for-pc/index.php',
+ 'D' => 'for-server/index.php',
);
} else {
$mga = array(
@@ -228,7 +239,7 @@
$num_of_col++;
if ($num_of_col % $num_clmns_to_repeat == 0 && $num_of_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) {
if ($l == 'en') {
- $cols .= $lang_coloumn = '<td style="font-weight: bold;"><a href="?l=all" title="see all languages">Language</a></td>';
+ $cols .= $lang_coloumn = '<td style="font-weight: bold;">Language</td>';
} else {
$cols .= $lang_coloumn = sprintf('<td style="font-weight: bold; vertical-align: top;">' . $link_one_language . '<br><span style="font-weight: normal; font-size: smaller;">%s</span></td>', $langs[$l], $l);
}
@@ -257,33 +268,50 @@
$en_language = array_shift($languages); // shift English for proper sorting
krsort($languages, SORT_NUMERIC);
- $enFiles = array_map(function ($e) { return str_replace('en/', '', $e); }, $enFiles);
// add language coloumn repeating
$lang_line = array();
$num_of_h_col = 0;
+ $add_last_coloumn = FALSE;
+ $resources = ($restore_resources ? '&nbsp;' : count($enFiles) . ' resources');
foreach ($enFiles as $lang_chunk) {
$num_of_h_col++;
- $lang_line[] = $lang_chunk;
+ if ($restore_resources) {
+ $lang_line[] = str_replace('en/', '', $lang_chunk);
+ } else {
+ $lang_line[] = '<a href="?r=' . $lang_chunk . '" title="see only this resource">' . str_replace('en/', '', $lang_chunk) . '</a>';
+ }
if ($num_of_h_col % $num_clmns_to_repeat == 0 && $num_of_h_col <= count($enFiles) - ($num_clmns_to_repeat / 3)) {
- $lang_line[] = '&nbsp;';
+ $lang_line[] = $resources;
+ $add_last_coloumn = TRUE;
}
}
- $lang_line[] = '&nbsp;';// last h coloumn
-
+ if ($add_last_coloumn) {
+ $lang_line[] = $resources;// last h coloumn
+ }
+
$thfiles = '<th>' . implode('</th><th>', $lang_line) . '</th>' . PHP_EOL;
- $count = count($otherLangs);
+ if ($restore_languages) {
+ echo '<p>Restore <a href="?l=all" title="see all languages">all languages</a>.</p>';
+ $count = '&nbsp;';
+ } else {
+ $count = count($otherLangs) . ' languages';
+ }
+ if ($restore_resources) {
+ echo '<p>Restore <a href="?r=all" title="see all resources">all resources</a>.</p>';
+ }
$chunks = array_chunk($languages, $num_lines_to_repeat = 8); // add header repeating
$table_body = array();
foreach ($chunks as $chunk) {
- $table_body = array_merge($table_body, $chunk, array(count($chunk) > ($num_lines_to_repeat / 2) ? '<tr><th>&nbsp;</th><th>File</th>' . $thfiles : ''));
+ $table_body = array_merge($table_body, $chunk, array(count($chunk) > ($num_lines_to_repeat / 2) ? '<tr><th>' . $count . '</th><th>' . $resources . '</th>' . $thfiles : ''));
}
array_unshift($table_body, $en_language); // unshift English back
$s = implode($table_body);
+
echo <<<S
<table border="1">
<thead><tr>
- <th><a href="?l=all" title="see all languages">{$count} languages</a></th>
+ <th>{$count}</th>
<th>Progress</th>
{$thfiles}
</tr></thead>