From 769be3d48e5612a73232b868cbd6cd35ab3515df Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 6 Nov 2008 13:47:09 +0100 Subject: po: po_link_to is safe, and fallbacks to a working value if needed warnings are displayed if it is set to an invalid or incompatible value (e.g. po_link_to=negotiated and disabled usedirs) Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 3b92583a1..1ef332d83 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -87,7 +87,7 @@ sub getsetup () { #{{{ type => "string", example => "current", description => "internal linking behavior (default/current/negotiated)", - safe => 0, + safe => 1, rebuild => 1, }, } #}}} @@ -107,16 +107,24 @@ sub checkconfig () { #{{{ 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_link_to} || - ! defined $config{po_link_to}) { - $config{po_link_to}="default"; - } if (! exists $config{po_translatable_pages} || ! defined $config{po_translatable_pages}) { $config{po_translatable_pages}=""; } - if ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) { - error(gettext("po_link_to=negotiated requires usedirs to be set")); + if (! exists $config{po_link_to} || + ! defined $config{po_link_to}) { + $config{po_link_to}='default'; + } + elsif ($config{po_link_to} != 'default' + && $config{po_link_to} != 'current' + && $config{po_link_to} != 'negotiated') { + warn(sprintf(gettext('po_link_to=%s is not a valid setting, falling back to po_link_to=default'), + $config{po_link_to})); + $config{po_link_to}='default'; + } + elsif ($config{po_link_to} eq "negotiated" && ! $config{usedirs}) { + 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$/; } #}}} -- cgit v1.2.3