From: intrigeri Date: Tue, 14 Oct 2008 22:35:17 +0000 (+0200) Subject: po plugin: added lang() custom PageSpec function X-Git-Tag: 3.15~431 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/ce9db8989655a71bba32159e0a342acc67a6451b?ds=inline po plugin: added lang() custom PageSpec function Signed-off-by: intrigeri --- diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 5abe9d419..05e57fab4 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -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