]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po(match_lang, match_currentlang): use the lang() function
authorintrigeri <intrigeri@boum.org>
Mon, 10 Nov 2008 20:30:06 +0000 (21:30 +0100)
committerintrigeri <intrigeri@boum.org>
Mon, 10 Nov 2008 20:30:06 +0000 (21:30 +0100)
... now that it exists, instead of duplicating it.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm

index 1754260ed8867b8e5ab32bfc9fbac15333f72f94..2ffccb7e09f1c25f3037f07cd28d1da487457097 100644 (file)
@@ -726,16 +726,7 @@ sub match_lang ($$;@) { #{{{
        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};
-       }
-
+       my $lang=IkiWiki::Plugin::po::lang($page);
        if ($lang!~/^$regexp$/i) {
                return IkiWiki::FailReason->new("file language is $lang, not $wanted");
        }
@@ -746,26 +737,13 @@ 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};
-       }
+       my $currentlang=IkiWiki::Plugin::po::lang($params{location});
+       my $lang=IkiWiki::Plugin::po::lang($page);
 
        if ($lang eq $currentlang) {
                return IkiWiki::SuccessReason->new("file language is the same as current one, i.e. $currentlang");