Hello

What do you think about usage of locale pragma in 2 TT core distribution modules: Template::Stash and Template::Filters ?

This would allow to use locale-dependent vmethods and filters (sort, upper, match, etc) with non-latin1 locales.

=Patch for Stash.pm

*** Stash.pm.orig       Thu Jul 21 11:04:34 2005
--- Stash.pm    Thu Jul 21 10:50:07 2005
*************** package Template::Stash;
*** 27,32 ****
--- 27,33 ----
 require 5.004;

 use strict;
+ use locale;
 use vars qw( $VERSION $DEBUG $ROOT_OPS $SCALAR_OPS $HASH_OPS $LIST_OPS );

 $VERSION = sprintf("%d.%02d", q$Revision: 2.86 $ =~ /(\d+)\.(\d+)/);

=Patch for Filters.pm

*** Filters.pm.orig     Thu Jul 21 11:07:16 2005
--- Filters.pm  Thu Jul 21 10:49:49 2005
*************** package Template::Filters;
*** 27,32 ****
--- 27,33 ----
 require 5.004;

 use strict;
+ use locale;
 use base qw( Template::Base );
 use vars qw( $VERSION $DEBUG $FILTERS $URI_ESCAPES $PLUGIN_FILTER );
 use Template::Constants;

=Sample template (require T::P::POSIX)
[%-
   # I use here new plugin module appeared on CPAN
   USE POSIX;
   # if required locale is not default one use setlocale from POSIX
   CALL POSIX::setlocale( POSIX.LC_ALL, 'ru_RU.KOI8-R' );
   # the only word which Andy know in Russian
   var = 'пиво';
-%]
[% var | upper %]
[% IF var.match( '\w+' ) %]Match works with russian letters[% END %]

=Output
ПИВО
Match works with russian letters

--
Best regards,
Lobanov Igor
[EMAIL PROTECTED]

http://www.template-toolkit.ru - Template Toolkit translations to Russian


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to