}
} #}}}
+sub buildtranslationscache() { #{{{
+ # use istranslation's side-effect
+ map istranslation($_), (keys %pagesources);
+} #}}}
+
+sub resettranslationscache() { #{{{
+ undef %translations;
+} #}}}
+
sub needsbuild () { #{{{
my $needsbuild=shift;
# a given master page was rendered because its source file was changed
@origneedsbuild=(@$needsbuild);
- # build %translations, using istranslation's side-effect
- map istranslation($_), (keys %pagesources);
+ buildtranslationscache();
# make existing translations depend on the corresponding master page
foreach my $master (keys %translations) {
return "";
} #}}}
+sub alreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ return ( exists $filtered{$page}{$destpage}
+ && $filtered{$page}{$destpage} eq 1 );
+} #}}}
+sub setalreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ $filtered{$page}{$destpage}=1;
+} #}}}
+sub unsetalreadyfiltered($$) { #{{{
+ my $page=shift;
+ my $destpage=shift;
+
+ if (exists $filtered{$page}{$destpage}) {
+ delete $filtered{$page}{$destpage};
+ }
+} #}}}
+sub resetalreadyfiltered() { #{{{
+ undef %filtered;
+} #}}}
+
# We use filter to convert PO to the master page's format,
# since the rest of ikiwiki should not work on PO files.
sub filter (@) { #{{{
my $content = decode_utf8(encode_utf8($params{content}));
return $content if ( ! istranslation($page)
- || ( exists $filtered{$page}{$destpage}
- && $filtered{$page}{$destpage} eq 1 ));
+ || alreadyfiltered($page, $destpage) );
# CRLF line terminators make poor Locale::Po4a feel bad
$content=~s/\r\n/\n/g;
# and Locale::Po4a::write() work.
unlink $infile, $outfile;
- $filtered{$page}{$destpage}=1;
+ setalreadyfiltered($page, $destpage);
return $content;
} #}}}
IkiWiki::rcs_update();
}
# Reinitialize module's private variables.
- undef %filtered;
- undef %translations;
+ resetalreadyfiltered();
+ resettranslationscache();
# Trigger a wiki refresh.
require IkiWiki::Render;
IkiWiki::refresh();
my %params=@_;
# as we're previewing or saving a page, the content may have
# changed, so tell the next filter() invocation it must not be lazy
- if (exists $filtered{$params{page}}{$params{page}}) {
- delete $filtered{$params{page}}{$params{page}};
- }
+ unsetalreadyfiltered($params{page}, $params{page});
return $params{content};
} #}}}