X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/43e5c905cb593b3b6e8ae0a636cae815f09a5ea2..eeeda1295f08337f1321860d2b839732a46786e4:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index c57a5d0f8..124164da7 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -10,7 +10,7 @@ use warnings; use strict; use IkiWiki 3.00; use Encode; -use Locale::Po4a::Common qw(nowrapi18n); +use Locale::Po4a::Common qw(nowrapi18n !/.*/); use Locale::Po4a::Chooser; use Locale::Po4a::Po; use File::Basename; @@ -103,7 +103,7 @@ sub getsetup () { }, po_translatable_pages => { type => "pagespec", - example => "!*/Discussion", + example => "* and !*/Discussion", description => "PageSpec controlling which pages are translatable", link => "ikiwiki/PageSpec", safe => 1, @@ -119,20 +119,18 @@ sub getsetup () { } sub checkconfig () { - foreach my $field (qw{po_master_language po_slave_languages}) { + foreach my $field (qw{po_master_language}) { if (! exists $config{$field} || ! defined $config{$field}) { error(sprintf(gettext("Must specify %s when using the %s plugin"), $field, 'po')); } } - if (! (keys %{$config{po_slave_languages}})) { - error(gettext("At least one slave language must be defined ". - "in po_slave_languages when using the po plugin")); - } + map { islanguagecode($_) or error(sprintf(gettext("%s is not a valid language code"), $_)); } ($config{po_master_language}{code}, keys %{$config{po_slave_languages}}); + if (! exists $config{po_translatable_pages} || ! defined $config{po_translatable_pages}) { $config{po_translatable_pages}=""; @@ -150,7 +148,16 @@ sub checkconfig () { warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default')); $config{po_link_to}='default'; } + push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/; + + if ($config{po_master_language}{code} ne 'en') { + # use translated underlay directories in preference + # to the untranslated ones + foreach my $underlay ('basewiki', reverse @{$config{underlaydirs}}) { + add_underlay("locale/".$config{po_master_language}{code}."/".$underlay); + } + } } sub needsbuild () { @@ -904,10 +911,10 @@ sub otherlanguagesloop ($) { } } return sort { - return -1 if $a->{code} eq $config{po_master_language}{code}; - return 1 if $b->{code} eq $config{po_master_language}{code}; - return $a->{language} cmp $b->{language}; - } @ret; + return -1 if $a->{code} eq $config{po_master_language}{code}; + return 1 if $b->{code} eq $config{po_master_language}{code}; + return $a->{language} cmp $b->{language}; + } @ret; } sub homepageurl (;$) {