[interchange-cvs] interchange - racke modified 3 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Fri Mar 29 13:48:00 2002
User: racke
Date: 2002-03-29 18:47:33 GMT
Modified: . MANIFEST
Modified: lib/Vend Util.pm
Added: code/SystemTag parse_locale.coretag
Log:
added parse_locale tag (already in stable)
Revision Changes Path
2.36 +1 -0 interchange/MANIFEST
rev 2.36, prev_rev 2.35
Index: MANIFEST
===================================================================
RCS file: /anon_cvs/repository/interchange/MANIFEST,v
retrieving revision 2.35
retrieving revision 2.36
diff -u -r2.35 -r2.36
--- MANIFEST 11 Mar 2002 22:12:59 -0000 2.35
+++ MANIFEST 29 Mar 2002 18:47:33 -0000 2.36
@@ -60,6 +60,7 @@
code/SystemTag/order.coretag
code/SystemTag/page.coretag
code/SystemTag/perl.coretag
+code/SystemTag/parse_locale.coretag
code/SystemTag/price.coretag
code/SystemTag/process.coretag
code/SystemTag/profile.coretag
1.1 interchange/code/SystemTag/parse_locale.coretag
rev 1.1, prev_rev 1.0
Index: parse_locale.coretag
===================================================================
UserTag parse_locale hasEndTag
UserTag parse_locale PosNumber 0
UserTag parse_locale MapRoutine Vend::Util::parse_locale
2.22 +27 -15 interchange/lib/Vend/Util.pm
rev 2.22, prev_rev 2.21
Index: Util.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Util.pm,v
retrieving revision 2.21
retrieving revision 2.22
diff -u -r2.21 -r2.22
--- Util.pm 16 Feb 2002 18:27:19 -0000 2.21
+++ Util.pm 29 Mar 2002 18:47:33 -0000 2.22
@@ -1,6 +1,6 @@
# Vend::Util - Interchange utility functions
#
-# $Id: Util.pm,v 2.21 2002/02/16 18:27:19 mheins Exp $
+# $Id: Util.pm,v 2.22 2002/03/29 18:47:33 racke Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -82,7 +82,7 @@
use Safe;
use subs qw(logError logGlobal);
use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.21 $, 10);
+$VERSION = substr(q$Revision: 2.22 $, 10);
BEGIN {
eval {
@@ -936,6 +936,30 @@
return $text;
}
+sub parse_locale {
+ my ($input) = @_;
+
+ # avoid copying big strings
+ my $r = ref($input) ? $input : \$input;
+
+ if($Vend::Cfg->{Locale}) {
+ my $key;
+ $$r =~ s~\[L(\s+([^\]]+))?\]([\000-\377]*?)\[/L\]~
+ $key = $2 || $3;
+ defined $Vend::Cfg->{Locale}{$key}
+ ? ($Vend::Cfg->{Locale}{$key}) : $3 ~eg;
+ $$r =~ s~\[LC\]([\000-\377]*?)\[/LC\]~
+ find_locale_bit($1) ~eg;
+ undef $Lang;
+ }
+ else {
+ $$r =~ s~\[L(?:\s+[^\]]+)?\]([\000-\377]*?)\[/L\]~$1~g;
+ }
+
+ # return scalar string if one get passed initially
+ return ref($input) ? $input : $$r;
+}
+
sub teleport_name {
my ($file, $teleport, $table) = @_;
my $db;
@@ -1072,19 +1096,7 @@
return unless defined $contents;
- if($locale and $Vend::Cfg->{Locale}) {
- my $key;
- $contents =~ s~\[L(\s+([^\]]+))?\]([\000-\377]*?)\[/L\]~
- $key = $2 || $3;
- defined $Vend::Cfg->{Locale}{$key}
- ? ($Vend::Cfg->{Locale}{$key}) : $3 ~eg;
- $contents =~ s~\[LC\]([\000-\377]*?)\[/LC\]~
- find_locale_bit($1) ~eg;
- undef $Lang;
- }
- else {
- $contents =~ s~\[L(?:\s+[^\]]+)?\]([\000-\377]*?)\[/L\]~$1~g;
- }
+ parse_locale(\$contents);
return $contents unless wantarray;
return ($contents, $record);