[interchange-cvs] interchange - ton modified lib/Vend/Util.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Wed Feb 15 04:27:54 EST 2006


User:      ton
Date:      2006-02-15 09:27:54 GMT
Modified:  lib/Vend Util.pm
Log:
	Added a feature to the currency tag in order to display
	textual representation of the currency symbol. The so
	called international currency symbol according to the
	ISO 4217 standard.

	Usage:
	1. Add int_currency_symbol entry to the locale table.
	2. Add the display option to tags, like:

	   [total-cost display=text]

		Valid values for the display option:
		- text		Displays 'EUR ', 'GBP ', 'USD '  (EUR 125.40)
		- none		No symbol, displays formatted number only. (125.40)
		- symbol	Default behavior (same as calling the tag
					without display option)

Revision  Changes    Path
2.90      +18 -5     interchange/lib/Vend/Util.pm


rev 2.90, prev_rev 2.89
Index: Util.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
retrieving revision 2.89
retrieving revision 2.90
diff -u -r2.89 -r2.90
--- Util.pm	12 Feb 2006 22:23:58 -0000	2.89
+++ Util.pm	15 Feb 2006 09:27:53 -0000	2.90
@@ -1,6 +1,6 @@
 # Vend::Util - Interchange utility functions
 #
-# $Id: Util.pm,v 2.89 2006/02/12 22:23:58 mheins Exp $
+# $Id: Util.pm,v 2.90 2006/02/15 09:27:53 ton Exp $
 # 
 # Copyright (C) 2002-2005 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -88,7 +88,7 @@
 use Vend::File;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.89 $, 10);
+$VERSION = substr(q$Revision: 2.90 $, 10);
 
 my $Eval_routine;
 my $Eval_routine_file;
@@ -502,15 +502,28 @@
 		return picture_format($amount, $loc->{price_picture}, $sep, $dec)
 			if defined $loc->{price_picture};
 		$fmt = "%." . $loc->{frac_digits} .  "f";
+
 		my $cs;
-		if($cs = ($loc->{currency_symbol} ||$loc->{currency_symbol} || '') ) {
+		my $display = lc($opt->{display}) || 'symbol';
+		my $sep_by_space = $loc->{p_sep_by_space};
+		if( $loc->{int_currency_symbol} && $display eq 'text' ) {
+			$cs = $loc->{int_currency_symbol};
+			$sep_by_space = 0;
+		}
+		elsif ( $display eq 'none' ) {
+			$cs = '';
+		}
+		elsif ( $display eq 'symbol' ) {
+			$cs = $loc->{currency_symbol} || '';
+		}
+		if($cs) {
 			if($loc->{p_cs_precedes}) {
 				$precede = $cs;
-				$precede = "$precede " if $loc->{p_sep_by_space};
+				$precede = "$precede " if $sep_by_space;
 			}
 			else {
 				$succede = $cs;
-				$succede = " $succede" if $loc->{p_sep_by_space};
+				$succede = " $succede" if $sep_by_space;
 			}
 		}
 	}








More information about the interchange-cvs mailing list