From: dpvc v. a. <we...@ma...> - 2005-07-12 22:43:18
|
Log Message: ----------- Make error messages potentially localizable (by making them use sprintf-style strings rather than variable subtitution). Modified Files: -------------- pg/macros: contextLimitedNumeric.pl contextLimitedPoint.pl contextLimitedPolynomial.pl contextLimitedVector.pl contextString.pl parserImplicitPlane.pl parserMultiPart.pl parserParametricLine.pl parserSolutionFor.pl Revision Data ------------- Index: parserParametricLine.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserParametricLine.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/parserParametricLine.pl -Lmacros/parserParametricLine.pl -u -r1.3 -r1.4 --- macros/parserParametricLine.pl +++ macros/parserParametricLine.pl @@ -80,7 +80,7 @@ Value::Error("A line can't be just a constant vector") unless $t; $p = Value::Point->new($line->eval($t=>0)); $v = Value::Vector->new($line->eval($t=>1) - $p); - Value::Error("Your formula isn't linear in the variable $t") + Value::Error("Your formula isn't linear in the variable %s",$t) unless $line == $p + Value::Formula->new($t) * $v; } Value::Error("The direction vector for a parametric line can't be the zero vector") Index: contextLimitedPoint.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPoint.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/contextLimitedPoint.pl -Lmacros/contextLimitedPoint.pl -u -r1.1 -r1.2 --- macros/contextLimitedPoint.pl +++ macros/contextLimitedPoint.pl @@ -26,7 +26,7 @@ &{$super."::_check"}($self); return if $self->checkNumbers; my $bop = $self->{def}{string} || $self->{bop}; - $self->Error("In this context, '$bop' can only be used with Numbers"); + $self->Error("In this context, '%s' can only be used with Numbers",$bop); } ############################################## @@ -69,7 +69,7 @@ &{$super."::_check"}($self); return if $self->checkNumber; my $uop = $self->{def}{string} || $self->{uop}; - $self->Error("In this context, '$uop' can only be used with Numbers"); + $self->Error("In this context, '%s' can only be used with Numbers",$uop); } ############################################## Index: contextString.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextString.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/contextString.pl -Lmacros/contextString.pl -u -r1.1 -r1.2 --- macros/contextString.pl +++ macros/contextString.pl @@ -26,7 +26,7 @@ my @strings = grep {not defined($context->strings->get($_)->{alias})} $context->strings->names; my $strings = join(', ',@strings[0..$#strings-1]).' or '.$strings[-1]; - $equation->Error("Your answer should be one of $strings"); + $equation->Error("Your answer should be one of %s",$strings); } package contextString::Formula; Index: parserMultiPart.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserMultiPart.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/parserMultiPart.pl -Lmacros/parserMultiPart.pl -u -r1.1 -r1.2 --- macros/parserMultiPart.pl +++ macros/parserMultiPart.pl @@ -132,7 +132,7 @@ sub new { my $self = shift; my $class = ref($self) || $self; my @data = @_; my @cmp; - Value::Error($class." lists can't be empty") if scalar(@data) == 0; + Value::Error("%s lists can't be empty",$class) if scalar(@data) == 0; foreach my $x (@data) { $x = Value::makeValue($x) unless Value::isValue($x); push(@cmp,$x->cmp(@ans_defaults)); Index: contextLimitedNumeric.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedNumeric.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/contextLimitedNumeric.pl -Lmacros/contextLimitedNumeric.pl -u -r1.1 -r1.2 --- macros/contextLimitedNumeric.pl +++ macros/contextLimitedNumeric.pl @@ -22,7 +22,7 @@ my $self = shift; $self->SUPER::_check; my $uop = $self->{def}{string} || $self->{uop}; - $self->Error("Can't use '$uop' in this context") + $self->Error("Can't use '%s' in this context",$uop) unless $self->{op}->class eq 'Number'; } Index: parserImplicitPlane.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserImplicitPlane.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/parserImplicitPlane.pl -Lmacros/parserImplicitPlane.pl -u -r1.5 -r1.6 --- macros/parserImplicitPlane.pl +++ macros/parserImplicitPlane.pl @@ -99,7 +99,7 @@ $vars = shift || [$$Value::context->variables->names]; $vars = [$vars] unless ref($vars) eq 'ARRAY'; $type = 'line' if scalar(@{$vars}) == 2; - Value::Error("Your formula doesn't look like an implicit $type") + Value::Error("Your formula doesn't look like an implicit %s",$type) unless $plane->type eq 'Equality'; # # Find the coefficients of the formula @@ -120,7 +120,7 @@ unless (Value::Formula->new($plane->{tree}{lop}) - Value::Formula->new($plane->{tree}{rop})) == $f; } - Value::Error("The equation of a $type must be non-zero somewhere") + Value::Error("The equation of a %s must be non-zero somewhere",$type) if ($N->norm == 0); $plane->{d} = $d; $plane->{N} = $N; $plane->{implicit} = $type; $plane->{isValue} = $plane->{isFormula} = 1; Index: contextLimitedVector.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedVector.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/contextLimitedVector.pl -Lmacros/contextLimitedVector.pl -u -r1.1 -r1.2 --- macros/contextLimitedVector.pl +++ macros/contextLimitedVector.pl @@ -47,9 +47,9 @@ return if $self->checkVectors; } my $bop = $self->{def}{string} || $self->{bop}; - $self->Error("In this context, '$bop' can only be used with Numbers") + $self->Error("In this context, '%s' can only be used with Numbers",$bop) if $self->{equation}{context}{flags}{vector_format} eq 'coordinate'; - $self->Error("In this context, '$bop' can only be used with Numbers or i,j and k"); + $self->Error("In this context, '%s' can only be used with Numbers or i,j and k",$bop); } # @@ -74,7 +74,7 @@ $self->{ijk}{$x} = $self->{ijk}{$x} || $op->{ijk}{$x}; } } - Value::Error("The constant '$duplicate' may appear only once in your formula") + Value::Error("The constant '%s' may appear only once in your formula",$duplicate) if $duplicate; } @@ -125,7 +125,7 @@ sub checkVectors { my $self = shift; my $bop = $self->{def}{string} || $self->{bop}; - $self->Error("In this context, '$bop' can only be used with Numbers"); + $self->Error("In this context, '%s' can only be used with Numbers",$bop); } ############################################## @@ -146,9 +146,9 @@ return if $self->checkVector; } my $uop = $self->{def}{string} || $self->{uop}; - $self->Error("In this context, '$uop' can only be used with Numbers") + $self->Error("In this context, '%s' can only be used with Numbers",$uop) if $self->{equation}{context}{flags}{vector_format} eq 'coordinate'; - $self->Error("In this context, '$uop' can only be used with Numbers or i,j and k"); + $self->Error("In this context, '%s' can only be used with Numbers or i,j and k",$uop); } sub checkVector {return 0} Index: contextLimitedPolynomial.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextLimitedPolynomial.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/contextLimitedPolynomial.pl -Lmacros/contextLimitedPolynomial.pl -u -r1.1 -r1.2 --- macros/contextLimitedPolynomial.pl +++ macros/contextLimitedPolynomial.pl @@ -178,7 +178,7 @@ &{$super."::_check"}($self); my $op = $self->{op}; return if LimitedPolynomail::isConstant($op); - $self->Error("You can only use '$self->{def}{string}' with monomials") + $self->Error("You can only use '%s' with monomials",$self->{def}{string}) if $op->{isPoly}; $self->{isPoly} = 2; $self->{powers} = {%{$op->{powers}}} if $op->{powers}; @@ -226,7 +226,7 @@ &{$super."::_check"}($self); my $arg = $self->{params}->[0]; return if LimitedPolynomial::isConstant($arg); - $self->Error("Function '$self->{name}' can only be used with numbers"); + $self->Error("Function '%s' can only be used with numbers",$self->{name}); } Index: parserSolutionFor.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/parserSolutionFor.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -Lmacros/parserSolutionFor.pl -Lmacros/parserSolutionFor.pl -u -r1.1 -r1.2 --- macros/parserSolutionFor.pl +++ macros/parserSolutionFor.pl @@ -103,7 +103,7 @@ # # Make sure professor's answer actually works # - Value::Error("Professor's answer of ".$p->string." does not satisfy the given equation") + Value::Error("Professor's answer of %s does not satisfy the given equation",$p->string) unless $p->f($p); # |