[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sync with NetBSD.org



In message <20060214.114139.123578600.jun@soum.co.jp>
  Jun Ebihara <jun@soum.co.jp> writes:
>> mogu での訳の作業場所は
>>   htdocs/guide/ja
> 
> あくまでも本家にコントリビュートすることが目的なので、
> こっちに1票。

ほかにご意見がないようなので、
こっちで作業を始めます。

>> 前者は、
>> 本家 htdocs の訳は htdocs/ja に置くというルールから外れることになり、
>> http://www.jp.NetBSD.org/ja/JP/Project/www-ja/status/
>> も動かないことになりますが、どうしましょうか。
> 
> 別に何か項目をつくるんでしょうか。

原文が pkgsrc 以下にある The pkgsrc guide のことを考えると、
いずれ、 (translation-assign.txt, translation-ignore.txt も含めて)
書き直しが必要になるので、てきとうです。
# というか、 pigu で pkgsrc は参照できるのでしょうか

Index: www-trans.pl
===================================================================
RCS file: /cvsroot/localsrc/cvsweb/www-trans.pl,v
retrieving revision 1.9
diff -u -r1.9 www-trans.pl
--- www-trans.pl	30 Jan 2001 03:24:10 -0000	1.9
+++ www-trans.pl	17 Feb 2006 15:04:28 -0000
@@ -1,20 +1,37 @@
 #!/usr/local/bin/perl
 $base = "/htdocs/www.netbsd.org/htdocs";
-$transbase = "/htdocs/www.jp.netbsd.org/ja";
+$transbase = "/htdocs/www.jp.netbsd.org";
 $assign = "/htdocs/www.jp.netbsd.org/JP/staff/translation-assign.txt";
 $ignorelist = "/htdocs/www.jp.netbsd.org/JP/staff/translation-ignore.txt";
 $urlcvsroot = "cvsroot=cvs.netbsd.org";
-$jproot = "/ftp/cvs/jproot/htdocs/ja";
+$jproot = "/ftp/cvs/jproot/htdocs";
 $urljproot = "cvsroot=jp.netbsd.org";
 
 $urlbase = "http://www.jp.netbsd.org";
-$urltransbase = "http://www.jp.netbsd.org/ja";
+$urltransbase = "http://www.jp.netbsd.org";
 $urlcvsweb = "http://www.jp.netbsd.org/cgi-bin/cvsweb.cgi/htdocs";
-$urltranscvsweb = "http://www.jp.netbsd.org/cgi-bin/cvsweb.cgi/htdocs/ja";
+$urltranscvsweb = "http://www.jp.netbsd.org/cgi-bin/cvsweb.cgi/htdocs";
 $tablestart = "<TABLE BORDER=1>\n" .
 	"<TR><TH>原文<TH>訳文<TH>原Rev<TH>訳Rev<TH>翻訳者<TH>状況\n";
 $tableend = "</TABLE>\n";
 
+my @module_conf = (
+	# XXX これは別ファイルにするですかね。
+	# 名前, 原文 (htdocs からの相対位置), 訳文 (htdocs からの相対位置)
+	"htdocs", "", "ja",
+	# "guide", "guide/en", "guide/ja",
+	# "internals", "Documentation/internals/en", "Documentation/internals/ja",
+ );
+
+my @module;
+while (my $key = shift(@module_conf)) {
+	$module[$i++] = {
+		"id" => $key,
+		"original" => shift(@module_conf),
+		"translation" => shift(@module_conf)
+	};
+}
+
 open(OUT, "|nkf -j") || die;
 
 print OUT <<EOF;
@@ -24,7 +41,6 @@
 </HEAD>
 
 <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
-$tablestart
 EOF
 
 open(ASSIGN, $assign) || die;
@@ -49,16 +65,49 @@
 	close(IGNORE);
 }
 
-open(LIST, "cd $transbase; find . -type f -print |") || die;
+# TOC
+print OUT "<UL>\n";
+foreach my $key (@module) {
+	printf OUT "\t<LI><A HREF=\"#%s\">%s</A>\n", $key->{"id"}, $key->{"id"};
+}
+print OUT "</UL>\n";
+
+foreach my $key (@module) {
+	&print_table($key->{"id"}, $key->{"original"}, $key->{"translation"});
+}
+
+print OUT <<EOF;
+</BODY>
+</HTML>
+EOF
+
+exit 0;
+
+sub print_table {
+	my ($module, $modulepath, $moduletranspath) = @_;
+	my (%exist, %transrev);
+
+	printf OUT "<H2 ID=\"%s\">%s</H2>\n", $module, $module;
+	print OUT $tablestart;
+
+	my $searchpath = $moduletranspath ? "./$moduletranspath" : ".";
+	my $grep;
+	foreach my $key (@module) {
+		if ( $key->{"translation"} =~ m/^$moduletranspath./ ) {
+			$grep .= " | grep -v $key->{\"translation\"} ";
+		}
+	}
+open(LIST, "cd $transbase; find $searchpath -type f -print $grep|") || die;
+# XXX $searchpath が存在しないとアレ
 while (<LIST>) {
 	chop;
 	if (/\/CVS\// || /\/Makefile$/ || /\.cvsignore/) {
 		next;
 	}
 	if (/\.html$/i) {
-		($l = $_) =~ s|\.html|.list|i;
+		(my $l = $_) =~ s|\.html||i;
 		$l = $transbase . "/" . $l;
-		if (-f $l) {
+		if (-f "${l}.list" || -f "${l}.xml") {
 			next;
 		}
 	}
@@ -67,6 +116,12 @@
 	($file = $_) =~ s|.*/(.*)|$1|;
 	($path = $_) =~ s|(.*)/.*|$1|;
 	$f = $_;
+	if ( $modulepath ) {
+		$f =~ s|^/$moduletranspath|/$modulepath|;
+	} else {
+		$f =~ s|^/$moduletranspath||;
+		# XXX $moduletranspath が "" だったりするとアレ
+	}
 	$exist{$f} = 1;
 
 	open(IDENT, "ident -q \"$transbase$path/$file\"|") || die;
@@ -80,7 +135,14 @@
 close(LIST);
 
 $i = 0;
-open(LIST, "cd $base; find . -type f -print| sort|") || die;
+	$searchpath = $modulepath ? "./$modulepath" : ".";
+	foreach my $key (@module) {
+		if ( $key->{"original"} =~ m/^$modulepath./ ) {
+			$grep .= " | grep -v $key->{\"original\"} ";
+		}
+	}
+open(LIST, "cd $base; find $searchpath -type f -print $grep| sort|") || die;
+# XXX $searchpath が存在しないとアレ
 while (<LIST>) {
 	chop;
 
@@ -93,13 +155,10 @@
 	}
 	next if $flag;
 
-	if (/^\.\/Changes/ && ! /index.list/) {
-		next;
-	}
 	if (/\.html$/i) {
-		($l = $_) =~ s|\.html|.list|i;
-		$l = $base . "/" . $l;
-		if (-f $l) {
+		($l = $_) =~ s|\.html||i;
+		$l = $base. "/" . $l;
+		if (-f "${l}.list" || -f "${l}.xml") {
 			next;
 		}
 	}
@@ -120,6 +179,13 @@
 	s|^\.||;
 	($file = $_) =~ s|.*/(.*)|$1|;
 	($path = $_) =~ s|(.*)/.*|$1|;
+	my $transpath = $path;
+	if ( $modulepath ) {
+		$transpath =~ s|^/$modulepath|/$moduletranspath|;
+	} else {
+		$transpath =~ s|^|/$moduletranspath|;
+		# XXX $moduletranspath が "" だったりするとアレ
+	}
 	$f = $_;
 
 	$rev = "<BR>";
@@ -135,7 +201,7 @@
 	print OUT "<TD><A HREF=\"$urlbase$path/$file\">$path/$file</A> ";
 	if (defined($exist{$f})) {
 		undef $exist{$f};
-		print OUT "<TD><A HREF=\"$urltransbase$path/$file\">訳文</A> ";
+		print OUT "<TD><A HREF=\"$urltransbase$transpath/$file\">訳文</A> ";
 	} else {
 		print OUT "<TD><BR> ";
 	}
@@ -144,7 +210,7 @@
 
 	if (defined($transrev{$f})) {
 		print OUT
-		    "<TD><A HREF=\"$urltranscvsweb$path/$file?$urljproot\">$transrev{$f}</A>";
+		    "<TD><A HREF=\"$urltranscvsweb$transpath/$file?$urljproot\">$transrev{$f}</A>";
 	} else {
 		print OUT "<TD><BR> ";
 	}
@@ -157,7 +223,7 @@
 				$status = "<TD BGCOLOR=\"#C0C000\"><A HREF=\"$urlcvsweb$path/$file.diff?r1=$transrev{$f}\&r2=$rev\&f=h\&$urlcvsroot\">更新待ち</A>";
 			} else {
 				if ($inspector{$f} eq "NOT-YET") {
-					open(RLOG, "rlog \"$jproot$path/$file\"|")
+					open(RLOG, "rlog \"$jproot$transpath/$file\"|")
 						|| die;
 					$symbol = 0;
 					$head = 0;
@@ -184,11 +250,11 @@
 						$symbol = 1;
 					    }
 					}
-					close(<RLOG>);
+					close(RLOG);
 
 					$status =
 					    "<TD BGCOLOR=\"#F0F000\">" .
-					    "<A HREF=\"$urltranscvsweb$path/$file" .
+					    "<A HREF=\"$urltranscvsweb$transpath/$file" .
 					    ".diff?r1=text\&tr1=$tnf" .
 					    "\&r2=text\&tr2=$head\&f=h" .
 					    "\&$urljproot\">" .
@@ -222,7 +288,4 @@
 }
 print OUT "$tableend\n";
 
-print OUT <<EOF;
-</BODY>
-</HTML>
-EOF
+}