diff options
author | intrigeri <intrigeri@boum.org> | 2008-10-15 00:35:17 +0200 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2008-10-18 15:49:11 +0200 |
commit | ce9db8989655a71bba32159e0a342acc67a6451b (patch) | |
tree | ee2ef40db5dcbfc9cbcbc76d9e65b4affcc940fc | |
parent | d07c6b707da7c22d6b744b8cf50e306766e11ba9 (diff) |
po plugin: added lang() custom PageSpec function
Signed-off-by: intrigeri <intrigeri@boum.org>
-rw-r--r-- | IkiWiki/Plugin/po.pm | 22 |
1 files changed, 22 insertions, 0 deletions
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 |