]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po plugin: added lang() custom PageSpec function
authorintrigeri <intrigeri@boum.org>
Tue, 14 Oct 2008 22:35:17 +0000 (00:35 +0200)
committerintrigeri <intrigeri@boum.org>
Sat, 18 Oct 2008 13:49:11 +0000 (15:49 +0200)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm

index 5abe9d4195863d0bbd697d2e45370e7643826c62..05e57fab453c92c8fc7af6cb3eaf8d6ea2de0ad7 100644 (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