use Encode;
use Locale::Po4a::Chooser;
use File::Temp;
+use Memoize;
+
+my %translations;
+memoize("istranslatable");
+memoize("_istranslation");
sub import {
hook(type => "getsetup", id => "po", call => \&getsetup);
hook(type => "checkconfig", id => "po", call => \&checkconfig);
- hook(type => "scan", id => "po", call => \&scan);
hook(type => "targetpage", id => "po", call => \&targetpage);
hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath);
hook(type => "tweakbestlink", id => "po", call => \&tweakbestlink);
push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/;
} #}}}
-sub scan (@) { #{{{
- my %params=@_;
- my $page=$params{page};
-
- # FIXME: cache (or memoize) the list of translatable/translation pages,
- # and/or istranslation/istranslated results
-} #}}}
-
sub targetpage (@) { #{{{
my %params = @_;
my $page=$params{page};
return pagespec_match($page, $config{po_translatable_pages});
} #}}}
-sub istranslation ($) { #{{{
+sub _istranslation ($) { #{{{
my $page=shift;
my $file=$pagesources{$page};
if (! defined $file) {
return istranslatable($masterpage);
} #}}}
+sub istranslation ($) { #{{{
+ my $page=shift;
+ if (_istranslation($page)) {
+ my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ $translations{$masterpage}{$lang}=$page unless exists $translations{$masterpage}{$lang};
+ return 1;
+ }
+ return 0;
+} #}}}
+
package IkiWiki::PageSpec;
use warnings;