[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#282030: Please warn about kommas in __Choices fields, they are unsupported by debconf



tags 282030 + patch
thanks

On Fri, Nov 19, 2004 at 10:21:20AM +0100, Andreas Metzler wrote:
> On 2004-11-19 Denis Barbier <barbier@linuxfr.org> wrote:
> > On Thu, Nov 18, 2004 at 10:28:21PM +0100, Andreas Metzler wrote:
> [...]
> > > Hmm. Doublechecking it looks like po-debconf _does_ escape commas:
> 
> > You are right, where is my brain?
> > I wrote in /usr/share/doc/intltool-debian/changelog.gz:
> >   * Handle escaped commas in __Choices fields.  Those escapes are a
> >     cdebconf extension, so until it is accepted by debconf, this new
> >     feature won't be documented.  Bugreport and patch sent by
> >     Matt Kraai, thanks.  Closes: #241188
> 
> > I am closing this bugreport, even if I do not know what to think
> > about the current situation.
> 
> Hello,
> Ok. Kommas in __Choices do not work currently (although po-debconf
> escapes them by putting '\,' instead of ',' into the generated merged
> template file). So lintian should warn about this error. Afaict this
> should work as a basic test:
> if grep -q -E '^Choices.*\\,' debian/package/templates ; the
>  echo "E: escaped komma in Choices, probably generated by komma in
>    translation of a __Choices field"
> fi
> 
> I wonder whether we will ever see support for \, in debconf, with it
> being orphaned, whenever we do it will be a PITA as it'll break
> backports to sarge.

As debconf splits Choices fields with
  split(/,\s+/, $this->choices)
in Question.pm, I prefer the attached patch.
It also catches errors caused by mismatched commas in _Choices fields.

Denis
Index: checks/debconf
===================================================================
--- checks/debconf	(revision 371)
+++ checks/debconf	(working copy)
@@ -134,11 +134,17 @@
 		    and $template->{default} ne 'false';
     }
 
-    for my $key (keys %$template) {
-	if (($key =~ /^choices-/) and
-	    ($template->{choices} && $template->{choices} !~ /^\s*$/) and 
-	    (! $template->{$key} || $template->{$key} =~ /^\s*$/)) {
-	    tag "empty-translated-choices", "$key";
+    if (($template->{choices} && $template->{choices} !~ /^\s*$/)) {
+      my $nrchoices = ($template->{choices} =~ s/,\s/, /g);
+      for my $key (keys %$template) {
+	  if ($key =~ /^choices-/) {
+	    if (! $template->{$key} || $template->{$key} =~ /^\s*$/) {
+		tag "empty-translated-choices", "$key";
+	    }
+	    if (($template->{$key} =~ s/,\s/, /g) != $nrchoices) {
+		tag "mismatch-translated-choices", "$key";
+	    }
+	  }
 	}
     }
 
Index: checks/debconf.desc
===================================================================
--- checks/debconf.desc	(revision 371)
+++ checks/debconf.desc	(working copy)
@@ -63,6 +63,18 @@
  is skipped (and nothing is selected). Please verify that the translation
  you're using is valid.
 
+Tag: mismatch-translated-choices
+Type: error
+Info: A `Choices:' field is a comma separated list, and translated
+ `Choices:' fields must have the exact same number of elements.  One
+ of the translations does not follow this rule, you should contact the
+ translator and request for a new translation where elements of `Choices:'
+ fields have no embedded commas.
+ .
+ Cdebconf understands escaped commas in such fields, but packages
+ outside the scope of debian-installer must not have them until they are
+ also supported by debconf.
+
 Tag: select-without-choices
 Type: error
 Info: Templates using the `select' or `multiselect' data types must provide

Reply to: