]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po: po_link_to is safe, and fallbacks to a working value if needed
authorintrigeri <intrigeri@boum.org>
Thu, 6 Nov 2008 12:47:09 +0000 (13:47 +0100)
committerintrigeri <intrigeri@boum.org>
Thu, 6 Nov 2008 12:47:09 +0000 (13:47 +0100)
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 <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index 3b92583a196410e11e53ee5c15cc80358a96d74e..1ef332d83b912c30eea567d116fe6b678cb549e1 100644 (file)
@@ -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$/;
 } #}}}
index ee6dbb09733bc0ba55dc39e77ee35dd6b0dd3813..93ece9fb9c311f5fc936fb65a95eaef94b825eff 100644 (file)
@@ -255,17 +255,6 @@ does. This is actually a duplicate for
 [[bugs/pagetitle_function_does_not_respect_meta_titles]], which might
 be fixed by something like [[todo/using_meta_titles_for_parentlinks]].
 
-### websetup
-
-Which configuration settings are safe enough for websetup, apart of
-`po_master_language`, `po_slave_languages` and `po_translatable_pages`
-that have been checked already?
-
-> `po_link_to` w/o usedirs causes ikiwiki to error out. If it were
-> changed to fall back to a safe setting in this case rather than
-> error, it would be safe.
-> --[[Joey]]
-
 ### backlinks
 
 `po_link_to = negotiated`: if a given translatable `sourcepage.mdwn`