[interchange-cvs] interchange - danb modified code/SystemTag/error.coretag

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Fri Apr 11 06:30:46 UTC 2008


User:      danb
Date:      2008-04-11 06:30:46 GMT
Modified:  code/SystemTag error.coretag
Log:
Allow default error labels to be set in the Locale.

The previous behavior was to use the variable name when no label was given. This change causes it to first check for a default label in the form of an error_label_${variable name} entry in the Locale configuration before falling back on just the variable name. As such, it is fully backwards compatible.

This is useful if you use Locale to override the error messages in core modules and also want to override the display of the label without setting up or modifying the profile everywhere the error may be displayed (with labels) on the site. For example:

Locale en_US <<EOF
{
# Override an error in Order.pm with one specific to this catalog.
"'%s' for item %s is not numeric/integer",
"We do not offer fractions of a product; however, the product is designed so that you may cut it to the exact dimensions needed. (The quantity you entered was '%s'.)",

# Also override the error label.
"error_label_mv_order_quantity",
"Quantity",

}
EOF

Revision  Changes    Path
1.10                 interchange/code/SystemTag/error.coretag


rev 1.10, prev_rev 1.9
Index: error.coretag
===================================================================
RCS file: /var/cvs/interchange/code/SystemTag/error.coretag,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- error.coretag	1 Aug 2007 10:52:45 -0000	1.9
+++ error.coretag	11 Apr 2008 06:30:46 -0000	1.10
@@ -5,14 +5,14 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  See the LICENSE file for details.
 # 
-# $Id: error.coretag,v 1.9 2007-08-01 10:52:45 kwalsh Exp $
+# $Id: error.coretag,v 1.10 2008-04-11 06:30:46 danb Exp $
 
 ### This is in package Vend::Interpolate, and may make reference
 ### to variables in that module
 UserTag error               Order        name
 UserTag error               addAttr
 UserTag error               PosNumber    1
-UserTag error               Version      $Revision: 1.9 $
+UserTag error               Version      $Revision: 1.10 $
 UserTag error               Routine      <<EOR
 sub set_error {
 	my ($error, $var, $opt) = @_;
@@ -89,7 +89,10 @@
 					$string .= " ($_)" if $opt->{show_var};
 					$string .= ": ";
 				} else {
-					$string .= "($_): ";
+					# Use the variable name unless Locale has a default label.
+					my $label = errmsg("error_label_${_}");
+					$label = $_ if $label eq "error_label_${_}";
+					$string .= "($label): ";
 				}
 			} else {
 				$string .= "$_: " if $opt->{show_var};







More information about the interchange-cvs mailing list