summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-10-15 01:23:19 +0200
committerintrigeri <intrigeri@boum.org>2008-10-18 15:49:12 +0200
commit886731612504bd4ac70244497b3313a20b7b6049 (patch)
tree93336c481c5ffe2fa508ec62e2a316e9588f0ac5 /IkiWiki/Plugin
parent6f858cd59f6bb0734da499b88f385fb6a61ac48e (diff)
po plugin: added currentlang() custom PageSpec function
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/po.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index 05e57fab4..aa592989b 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -394,4 +394,34 @@ sub match_lang ($$;@) { #{{{
}
} #}}}
+sub match_currentlang ($$;@) { #{{{
+ my $page=shift;
+ shift;
+ my %params=@_;
+ my ($currentmasterpage, $currentlang, $masterpage, $lang);
+
+ return IkiWiki::FailReason->new("no location provided") unless exists $params{location};
+
+ if (IkiWiki::Plugin::po::istranslation($params{location})) {
+ ($currentmasterpage, $currentlang) = ($params{location} =~ /(.*)[.]([a-z]{2})$/);
+ }
+ else {
+ $currentlang = $config{po_master_language}{code};
+ }
+
+ if (IkiWiki::Plugin::po::istranslation($page)) {
+ ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/);
+ }
+ else {
+ $lang = $config{po_master_language}{code};
+ }
+
+ if ($lang eq $currentlang) {
+ return IkiWiki::SuccessReason->new("file language is the same as current one, i.e. $currentlang");
+ }
+ else {
+ return IkiWiki::FailReason->new("file language is $lang, whereas current language is $currentlang");
+ }
+} #}}}
+
1