+ my $page = $params{page};
+ my $content = $params{content};
+ my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ my $masterfile = srcfile($pagesources{$masterpage});
+
+ # force content to be htmlize'd as if it was the same type as the master page
+ return IkiWiki::htmlize($page, $page, pagetype($masterfile), $content);
+} #}}}
+
+package IkiWiki::PageSpec;
+use warnings;
+use strict;
+use IkiWiki 2.00;
+
+sub match_istranslation ($;@) { #{{{
+ my $page=shift;
+ my $wanted=shift;
+
+ my %params=@_;
+ my $file=exists $params{file} ? $params{file} : $pagesources{$page};
+ if (! defined $file) {
+ return IkiWiki::FailReason->new("no file specified");
+ }
+
+ if (! defined pagetype($file) || ! pagetype($file) eq 'po') {
+ return IkiWiki::FailReason->new("is not a PO file");
+ }
+
+ my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ if (! defined $masterpage || ! defined $lang
+ || ! (length($masterpage) > 0) || ! (length($lang) > 0)) {
+ return IkiWiki::FailReason->new("is not named like a translation file");
+ }
+
+ if (! defined $pagesources{$masterpage}) {
+ return IkiWiki::FailReason->new("the master page does not exist");
+ }
+
+ if (! defined $config{po_slave_languages}{$lang}) {
+ return IkiWiki::FailReason->new("language $lang is not supported");
+ }
+
+ return IkiWiki::SuccessReason->new("page $page is a translation");
+} #}}}
+
+sub match_istranslatable ($;@) { #{{{
+ my $page=shift;
+ my $wanted=shift;
+
+ my %params=@_;
+ my $file=exists $params{file} ? $params{file} : $pagesources{$page};
+ if (! defined $file) {
+ return IkiWiki::FailReason->new("no file specified");
+ }
+
+ if (defined pagetype($file) && pagetype($file) eq 'po') {
+ return IkiWiki::FailReason->new("is a PO file");
+ }
+ if ($file =~ /\.pot$/) {
+ return IkiWiki::FailReason->new("is a POT file");
+ }
+
+ foreach my $registering_page (keys %pagestate) {
+ if (exists $pagestate{$registering_page}{po_translatable}) {
+ foreach my $pagespec (sort keys %{$pagestate{$registering_page}{po_translatable}}) {
+ if (pagespec_match($page, $pagespec, location => $registering_page)) {
+ return IkiWiki::SuccessReason->new("is set as translatable on $registering_page");
+ }
+ }
+ }
+ }
+
+ return IkiWiki::FailReason->new("is not set as translatable");