In the following example, one page is English only, while the other has German and English content.
2003-02-11 * (diff) SiteMap 0:51 UTC (8 changes) [less stuff] [en] . . . . . AlexSchroeder 2003-02-10 * (diff) SandBox 23:28 UTC (9 changes) [deutsches zeug dazu] [de, en] . . . . . AlexSchroeder
To filter, use the new rclang parameter. The parameters action=rc&rclang=de will yield the pages with de content only.
2003-02-10 * (diff) SandBox 23:28 UTC (9 changes) [deutsches zeug dazu] [de, en] . . . . . AlexSchroeder
New variables for the section at the beginning:
%Languages $LanguageLimit
Set %Languages to something useful. This is a hash with key being a language code, and value being a regexp matching some small common words in that language. The default is empty:
# Example: %Languages = ('de' => '\b(der|die|das|und|oder)\b'); %Languages = (); $LanguageLimit = 3; # Number of matches req. for each language
A possible value would be this one here:
%Languages = ( 'en' => '\b(the|that|and|why|what)\b', 'de' => '\b(der|die|das|und|oder)\b', 'fr' => '\b(et|une|les|ou|est|que)\b', 'it' => '\b(il|gli|che|perchè|così)\b', );
In GetRc? (this assumes WikiPatches/ModWiki):
Add a new local variable, and in the final foreach loop at the end, use it. Pass a reference to it along to the print RC line function, too.
... my @languages; ... next if (not $all and $ts < $changetime{$pagename}); next if ($idOnly and $idOnly ne $pagename); %extra = split(/$FS2/, $extraTemp, -1); @languages = split(/$FS1/, $extra{'languages'}); next if ($langFilter and not grep(/$langFilter/, @languages)); if ($date ne &CalcDay($ts)) { $date = &CalcDay($ts); &$printDailyTear($date); } &$printRCLine( $pagename, $ts, $host, $extra{'name'}, $summary, $isEdit, $pagecount{$pagename}, $extra{'revision'}, \@languages); } }
In GetRcHtml:
The printRCLine accepts a new parameter, $languages, and uses a new local variable, $lang. $lang holds the textual description of the languages and is added after the summary.
# printRCLine sub { my($pagename, $timestamp, $host, $userName, $summary, $isEdit, $pagecount, $revision, $languages) = @_; my($author, $sum, $edit, $count, $link, $difftype, $lang); ... $lang = ''; if (@{$languages}) { $lang = '[' . join(', ', @{$languages}) . '] '; } $link = ''; if ($UseDiff && &GetParam('diffrclink', 1)) { if ($isEdit) { $difftype = 2; # minor } else { $difftype = 1; # major } $link .= &ScriptLinkDiff($difftype, $pagename, $tDiff, '') . ' '; } $link .= &GetPageLink($pagename); $html .= "<li>$link "; # Later do new-RC looping here. $html .= &CalcTime($timestamp) . " $count$edit $sum$lang"; $html .= ". . . . . $author\n"; # Make dots optional? }, @_; $html .= "</UL>\n" if ($inlist); return $html; }
In DoPost?:
When writing the RC entries, determine the languages used and save that information:
&SaveDefaultText(); &SavePage(); &WriteRcLog($id, $summary, $isEdit, $editTime, $Section{'revision'}, $user, $Section{'host'}, &GetLanguages($Text{'text'})); if ($UseIndex && ($Page{'revision'} == 1)) { unlink($IndexFile); # Regenerate index on next request } &ReleaseLock(); &ReBrowsePage($id, '', 1); }
This requires the new sub GetLanguages:
sub GetLanguages { my ($text) = @_; my @result; my $count; for my $lang (keys %Languages) { $count = 0; while ($text =~ /$Languages{$lang}/ig) { if (++$count > $LanguageLimit) { push(@result, $lang); last; } } } return \@result; }
The final missing link is the extension of WriteRcLog?:
sub WriteRcLog { my ($id, $summary, $isEdit, $editTime, $revision, $name, $rhost, $languages) = @_; my ($extraTemp, %extra); %extra = (); $extra{'name'} = $name if ($name ne ''); $extra{'revision'} = $revision if ($revision ne ''); $extra{'languages'} = join($FS1, @{$languages}) if $languages; $extraTemp = join($FS2, %extra); # The two fields at the end of a line are kind and extension-hash my $rc_line = join($FS3, $editTime, $id, $summary, $isEdit, $rhost, '0', $extraTemp); if (!open(OUT, ">>$RcFile")) { die(Ts('%s log error:', $RCName) . " $!"); } print OUT $rc_line . "\n"; close(OUT); }