]> sipb.mit.edu Git - ikiwiki.git/commitdiff
yesno: Always accept English even when localised.
authorJoey Hess <joey@gnu.kitenet.net>
Sat, 3 Jan 2009 17:52:47 +0000 (12:52 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Sat, 3 Jan 2009 17:52:47 +0000 (12:52 -0500)
It seems to be a failing of i18n in unix that the translation stops at the
commands and the parameters to them, and ikiwiki is no exception with its
currently untranslated directives. So the little bit that's translated sticks
out like a sore thumb. It also breaks building of wikis if a different locale
happens to be set.

I suppose the best thing to do is either give up on the localisation of this
part completly, or make it recognise English in addition to the locale. I've
tenatively chosen the latter.

(Also accept 1 and 0 as input.)

IkiWiki.pm
debian/changelog
t/yesno.t [new file with mode: 0755]

index e509a7c2f4202cc6016d8b294a02db9c8d34426a..7eef4c320f40b211372aa09b7be4e785a02d97ad 100644 (file)
@@ -1658,7 +1658,7 @@ sub gettext {
 sub yesno ($) {
        my $val=shift;
 
-       return (defined $val && lc($val) eq gettext("yes"));
+       return (defined $val && (lc($val) eq gettext("yes") || lc($val) eq "yes" || $val eq "1"));
 }
 
 sub inject {
index 0f2c75787116a653b719d887037f140a3dfea5e4..f892dc5246063f92405089a08d3166a541c85a52 100644 (file)
@@ -3,6 +3,8 @@ ikiwiki (3.01) UNRELEASED; urgency=low
   * ikiwiki-makerepo: Fix injecting of empty mercurial and bzr repositories.
     Closes: #510518
   * Fix documentation about git hook to use right name. Closes: #510393
+  * yesno: Always accept English even when localised.
+  * yesno: Also accept 1 and 0 as input.
 
  -- Joey Hess <joeyh@debian.org>  Fri, 02 Jan 2009 14:12:16 -0500
 
diff --git a/t/yesno.t b/t/yesno.t
new file mode 100755 (executable)
index 0000000..60a8c07
--- /dev/null
+++ b/t/yesno.t
@@ -0,0 +1,21 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 10;
+
+BEGIN { use_ok("IkiWiki"); }
+
+# note: yesno always accepts English even if localized.
+# So no need to bother setting locale to C.
+
+ok(IkiWiki::yesno("yes") == 1);
+ok(IkiWiki::yesno("Yes") == 1);
+ok(IkiWiki::yesno("YES") == 1);
+
+ok(IkiWiki::yesno("no") == 0);
+ok(IkiWiki::yesno("No") == 0);
+ok(IkiWiki::yesno("NO") == 0);
+
+ok(IkiWiki::yesno("1") == 1);
+ok(IkiWiki::yesno("0") == 0);
+ok(IkiWiki::yesno("mooooooooooo") == 0);