po plugin: added lang() custom PageSpec function

Signed-off-by: intrigeri <intrigeri@boum.org>
master
intrigeri 2008-10-15 00:35:17 +02:00
parent d07c6b707d
commit ce9db89896
1 changed files with 22 additions and 0 deletions

View File

@ -372,4 +372,26 @@ sub match_istranslatable ($;@) { #{{{
}
} #}}}
sub match_lang ($$;@) { #{{{
my $page=shift;
my $wanted=shift;
my $regexp=IkiWiki::glob2re($wanted);
my $lang;
my $masterpage;
if (IkiWiki::Plugin::po::istranslation($page)) {
($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
}
else {
$lang = $config{po_master_language}{code};
}
if ($lang!~/^$regexp$/i) {
return IkiWiki::FailReason->new("file language is $lang, not $wanted");
}
else {
return IkiWiki::SuccessReason->new("file language is $wanted");
}
} #}}}
1