[Catalyst-commits] r7358 - in trunk/Catalyst-Plugin-I18N: . lib/Catalyst/Plugin

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Mon Jan 7 15:45:53 GMT 2008


Author: bricas
Date: 2008-01-07 15:45:52 +0000 (Mon, 07 Jan 2008)
New Revision: 7358

Modified:
   trunk/Catalyst-Plugin-I18N/Changes
   trunk/Catalyst-Plugin-I18N/lib/Catalyst/Plugin/I18N.pm
Log:
allow Locale::Maketext::Simple options to be overridden

Modified: trunk/Catalyst-Plugin-I18N/Changes
===================================================================
--- trunk/Catalyst-Plugin-I18N/Changes	2008-01-07 14:25:11 UTC (rev 7357)
+++ trunk/Catalyst-Plugin-I18N/Changes	2008-01-07 15:45:52 UTC (rev 7358)
@@ -1,6 +1,8 @@
 Revision history for Perl extension Catalyst::Plugin::I18N.
 
-0.07  xxx xxx xx 2007
+0.07  Mon Jan 07 2008
+        - allow overriding of options sent to Locale::Maketext::Simple (RT #32132)
+        - include a draft manual from a while back
         - Makefile.PL updates
 
 0.06  Tue Jul 17 2007

Modified: trunk/Catalyst-Plugin-I18N/lib/Catalyst/Plugin/I18N.pm
===================================================================
--- trunk/Catalyst-Plugin-I18N/lib/Catalyst/Plugin/I18N.pm	2008-01-07 14:25:11 UTC (rev 7357)
+++ trunk/Catalyst-Plugin-I18N/lib/Catalyst/Plugin/I18N.pm	2008-01-07 15:45:52 UTC (rev 7358)
@@ -1,6 +1,8 @@
 package Catalyst::Plugin::I18N;
 
 use strict;
+use warnings;
+
 use NEXT;
 use I18N::LangTags ();
 use I18N::LangTags::Detect;
@@ -8,6 +10,7 @@
 require Locale::Maketext::Simple;
 
 our $VERSION = '0.07';
+our %options = ( Export => '_loc', Decode => 1 );
 
 =head1 NAME
 
@@ -46,6 +49,20 @@
    our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
    1;
 
+=head2 CONFIGURATION
+
+You can override any parameter sent to L<Locale::Maketext::Simple> by specifying
+a C<maketext_options> hashref to the C<Plugin::I18N> config section. For
+example, the following configuration will override the C<Decode> parameter which
+normally defaults to C<1>:
+
+    __PACKAGE__->config(
+        'Plugin::I18N' =>
+            maketext_options => {
+                Decode => 0
+            }
+    );
+
 =head2 EXTENDED METHODS
 
 =head3 setup
@@ -56,13 +73,17 @@
     my $self = shift;
     $self->NEXT::setup(@_);
     my $calldir = $self;
-    $calldir =~ s#::#/#g;
+    $calldir =~ s{::}{/}g;
     my $file = "$calldir.pm";
     my $path = $INC{$file};
-    $path =~ s#\.pm$#/I18N#;
+    $path =~ s{\.pm$}{/I18N};
+
+    my $user_opts = $self->config->{ 'Plugin::I18N' }->{ maketext_options } || {};
+    local %options = ( %options, Path => $path, %$user_opts );
+
     eval <<"";
-      package $self;
-      import Locale::Maketext::Simple Path => '$path', Export => '_loc', Decode => 1;
+        package $self;
+        Locale::Maketext::Simple->import( \%Catalyst\::Plugin\::I18N\::options );
 
 
     if ($@) {




More information about the Catalyst-commits mailing list