[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] com doc/base: ported Translator's table.: scripts/revcheck.php
From: Yoshinari Takaoka <mumumu () php ! net>
Date: 2021-03-26 19:48:16
Message-ID: php-mail-11f223759c406369f7603b38e827a4b11920119286 () git ! php ! net
[Download RAW message or body]
Commit: a624cf5c681c2d41bbeb57be689413a3807361f2
Author: Yoshinari Takaoka <mumumu@mumumu.org> Sat, 27 Mar 2021 04:48:16 \
+0900
Parents: 8f25cb80612530afe44dd66689f0fbceb8cfa0e9
Branches: master
Link: http://git.php.net/?p=doc/base.git;a=commitdiff;h=a624cf5c681c2d41bbeb57be689413a3807361f2
Log:
ported Translator's table.
In original revcheck.php, we can select [files|status] by maintainar, but its \
functionality is left as TODO.
Changed paths:
M scripts/revcheck.php
Diff:
diff --git a/scripts/revcheck.php b/scripts/revcheck.php
index d9ad2b30c..89fd65c41 100644
--- a/scripts/revcheck.php
+++ b/scripts/revcheck.php
@@ -57,8 +57,9 @@ captureGitValues( 'en' , $gitData );
captureGitValues( $lang , $gitData );
computeSyncStatus( $enFiles , $trFiles , $gitData , $lang );
+$translators = computeTranslatorStatus( $lang, $enFiles, $trFiles );
-print_html_all( $enFiles , $trFiles , $lang );
+print_html_all( $enFiles , $trFiles , $translators, $lang );
// Model
@@ -91,6 +92,46 @@ class FileStatusInfo
}
}
+class TranslatorInfo
+{
+ public $name;
+ public $email;
+ public $nick;
+ public $vcs;
+
+ public $files_uptodate;
+ public $files_outdated;
+ public $files_wip;
+ public $files_sum;
+ public $files_other;
+
+ public function __construct() {
+ $this->files_uptodate = 0;
+ $this->files_outdated = 0;
+ $this->files_wip = 0;
+ $this->files_sum = 0;
+ $this->files_other = 0;
+ }
+
+ public static function getKey( $fileStatus ) {
+ switch ( $fileStatus ) {
+ case FileStatusEnum::Untranslated:
+ case FileStatusEnum::TranslatedOld:
+ case FileStatusEnum::TranslatedCritial:
+ return "files_outdated";
+ break;
+ case FileStatusEnum::TranslatedWip:
+ return "files_wip";
+ break;
+ case FileStatusEnum::TranslatedOk:
+ return "files_uptodate";
+ break;
+ default:
+ return "files_other";
+ }
+ }
+}
+
function populateFileTree( $lang )
{
$dir = new \DirectoryIterator( $lang );
@@ -269,13 +310,82 @@ function computeSyncStatus( $enFiles , $trFiles , $gitData , \
$lang ) }
}
+function parse_attr_string ( $tags_attrs ) {
+ $tag_attrs_processed = array();
+
+ foreach($tags_attrs as $attrib_list) {
+ preg_match_all("!(.+)=\\s*([\"'])\\s*(.+)\\2!U", $attrib_list, $attribs);
+
+ $attrib_array = array();
+ foreach ($attribs[1] as $num => $attrname) {
+ $attrib_array[trim($attrname)] = trim($attribs[3][$num]);
+ }
+
+ $tag_attrs_processed[] = $attrib_array;
+ }
+
+ return $tag_attrs_processed;
+}
+
+function computeTranslatorStatus( $lang, $enFiles, $trFiles ) {
+ $translation_xml = getcwd() . "/" . $lang . "/translation.xml";
+ if (!file_exists($translation_xml)) {
+ return [];
+ }
+
+ $txml = join("", file($translation_xml));
+ $txml = preg_replace("/\\s+/", " ", $txml);
+
+ preg_match("!<\?xml(.+)\?>!U", $txml, $match);
+ $xmlinfo = parse_attr_string($match);
+ $output_charset = $xmlinfo[1]["encoding"];
+
+ $pattern = "!<person(.+)/\\s?>!U";
+ preg_match_all($pattern, $txml, $matches);
+ $translators = parse_attr_string($matches[1]);
+
+ $translatorInfos = [];
+ $unknownInfo = new TranslatorInfo();
+ $unknownInfo->nick = "unknown";
+ $translatorInfos["unknown"] = $unknownInfo;
+
+ foreach ($translators as $key => $translator) {
+ $info = new TranslatorInfo();
+ $info->name = $translator["name"];
+ $info->email = $translator["email"];
+ $info->nick = $translator["nick"];
+ $info->vcs = $translator["vcs"];
+
+ $translatorInfos[$info->nick] = $info;
+ }
+
+ foreach( $enFiles as $key => $enFile ) {
+ $statusKey = TranslatorInfo::getKey($enFile->syncStatus);
+ $info_exists = false;
+ if (array_key_exists($enFile->getKey(), $trFiles)) {
+ $trFile = $trFiles[$enFile->getKey()];
+ if (array_key_exists($trFile->maintainer, $translatorInfos)) {
+ $translatorInfos[$trFile->maintainer]->$statusKey++;
+ $translatorInfos[$trFile->maintainer]->files_sum++;
+ $info_exists = true;
+ }
+ }
+ if (!$info_exists) {
+ $translatorInfos["unknown"]->$statusKey++;
+ $translatorInfos["unknown"]->files_sum++;
+ }
+ }
+
+ return $translatorInfos;
+}
+
// Output
-function print_html_all( $enFiles , $trFiles , $lang )
+function print_html_all( $enFiles , $trFiles , $translators , $lang )
{
print_html_header( $lang );
- //print_html_introduction();
- //print_html_translations();
+ print_html_menu( 'menus' );
+ print_html_translators($translators);
//print_html_filesumary();
print_html_files( $enFiles , $trFiles , $lang );
//print_html_wip();
@@ -338,6 +448,53 @@ function print_html_menu( $href )
HTML;
}
+function print_html_translators( $translators ) {
+
+ if (count($translators) === 0) return;
+
+ print <<<HTML
+
+<a name="translators"></a>
+<table width="820" border="0" cellpadding="4" cellspacing="1" align="center">
+ <tr class=blue>
+ <th rowspan=2>Translator's name</th>
+ <th rowspan=2>Contact email</th>
+ <th rowspan=2>Nick</th>
+ <th rowspan=2>V<br>C<br>S</th>
+ <th colspan=4>Files maintained</th>
+ </tr>
+ <tr>
+ <th style="color:#000000">upto-<br>date</th>
+ <th style="color:#000000">old</th>
+ <th style="color:#000000">wip</th>
+ <th class="blue">sum</th>
+ </tr>
+HTML;
+
+ foreach( $translators as $key => $person )
+ {
+ if ($person->nick === "unknown") continue;
+
+ print <<<HTML
+
+<tr>
+ <td>{$person->name}</td>
+ <td>{$person->email}</td>
+ <td>{$person->nick}</td>
+ <td class=c>{$person->vcs}</td>
+
+ <td class=c>{$person->files_uptodate}</td>
+ <td class=c>{$person->files_outdated}</td>
+ <td class=c>{$person->files_wip}</td>
+ <td class=c>{$person->files_sum}</td>
+</tr>
+
+HTML;
+
+ }
+ print "</table>\n";
+}
+
function print_html_untranslated($enFiles)
{
$exists = false;
@@ -387,7 +544,6 @@ HTML;
HTML;
}
print "</table>\n";
- print "<p> </p>\n";
}
function print_html_footer()
@@ -411,8 +567,10 @@ HTML;
function print_html_files( $enFiles , $trFiles , $lang )
{
- print_html_menu( 'files' );
print <<<HTML
+
+<p> </p>
+<a name="files"></a>
<table>
<tr>
<th rowspan="2">Translated file</th>
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic