[ic] Contribution: UserTag loci - Allows for localization within contained tags

Ton Verhagen ton@verhagen.net
Mon, 20 Nov 2000 11:04:24 +0100

Dear All,

While localizing a site I had the need for an UserTag like [LC] ... [/LC] 
that would also work within contained tags.
I made an equivalent of the [LC] ... [/LC] tag that will do the job when 
used in included files (both low and high traffic settings).

I'd like to contribute the loci UserTag to the IC community and I hope you 
will find it useful.

All the best,

Ton Verhagen

# [loci]
# Default message
# [nl_NL] Dutch message [/nl_NL]
# [de_DE] German message [/de_DE]
# [/loci]
# This tag is the equivalent of [LC] ... [/LC] localization, except
# it also works within contained tags
UserTag loci hasEndTag   1
UserTag loci Interpolate 1
UserTag loci Routine <<EOF
my $Lang;
sub {
     my $text = shift;
     $Lang = $::Scratch->{mv_locale} unless defined $Lang;
#::logDebug("loci: $Lang");
     $text =~ m{\[$Lang\](.*)\[/$Lang\]}s
             and return $1;
     $text =~ s{\[(\w+)\].*\[/\1\].*}{}s;
     return $text;