[Rt-commit] r5015 - in Locale-Maketext-Lexicon: . inc/Module/Install lib/Locale/Maketext t

autrijus at bestpractical.com autrijus at bestpractical.com
Tue Apr 11 08:12:53 EDT 2006


Author: autrijus
Date: Tue Apr 11 08:12:51 2006
New Revision: 5015

Added:
   Locale-Maketext-Lexicon/t/6-gettext.t   (contents, props changed)
Modified:
   Locale-Maketext-Lexicon/Changes
   Locale-Maketext-Lexicon/inc/Module/Install.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Base.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Can.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Fetch.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Makefile.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Metadata.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Scripts.pm
   Locale-Maketext-Lexicon/inc/Module/Install/Win32.pm
   Locale-Maketext-Lexicon/inc/Module/Install/WriteAll.pm
   Locale-Maketext-Lexicon/lib/Locale/Maketext/Lexicon.pm

Log:
* This be 0.57.
* Locale::Maketext::Locale: The "_style => 'gettext'" option was
  broken for function forms such as "%quant(%1)", as well as
  adjacent variables such as "%1%2%3".


Modified: Locale-Maketext-Lexicon/Changes
==============================================================================
--- Locale-Maketext-Lexicon/Changes	(original)
+++ Locale-Maketext-Lexicon/Changes	Tue Apr 11 08:12:51 2006
@@ -1,3 +1,9 @@
+[Changes for 0.57 - 2006-04-11]
+
+* Locale::Maketext::Locale: The "_style => 'gettext'" option was
+  broken for function forms such as "%quant(%1)", as well as
+  adjacent variables such as "%1%2%3".
+
 [Changes for 0.56 - 2006-04-02]
 
 * Locale::Maketext::Lexicon: Specifying the new "_auto => 1" option

Modified: Locale-Maketext-Lexicon/inc/Module/Install.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install.pm	Tue Apr 11 08:12:51 2006
@@ -28,7 +28,7 @@
     # This is not enforced yet, but will be some time in the next few
     # releases once we can make sure it won't clash with custom
     # Module::Install extensions.
-    $VERSION = '0.61';
+    $VERSION = '0.62';
 }
 
 # Whether or not inc::Module::Install is actually loaded, the
@@ -196,7 +196,6 @@
         unshift @INC, $self->{prefix};
     }
 
-    local @INC = ($path, @INC);
     foreach my $rv ( $self->find_extensions($path) ) {
         my ($file, $pkg) = @{$rv};
         next if $self->{pathnames}{$pkg};

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Base.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Base.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Base.pm	Tue Apr 11 08:12:51 2006
@@ -1,7 +1,7 @@
 #line 1
 package Module::Install::Base;
 
-$VERSION = '0.61';
+$VERSION = '0.62';
 
 # Suspend handler for "redefined" warnings
 BEGIN {

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Can.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Can.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Can.pm	Tue Apr 11 08:12:51 2006
@@ -9,13 +9,13 @@
 use File::Spec ();
 use ExtUtils::MakeMaker ();
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.61';
+	$VERSION = '0.62';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
-
 # check if we can load some module
 ### Upgrade this to not have to load the module if possible
 sub can_use {

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Fetch.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Fetch.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Fetch.pm	Tue Apr 11 08:12:51 2006
@@ -4,9 +4,10 @@
 use strict;
 use Module::Install::Base;
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.61';
+	$VERSION = '0.62';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Makefile.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Makefile.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Makefile.pm	Tue Apr 11 08:12:51 2006
@@ -5,9 +5,10 @@
 use Module::Install::Base;
 use ExtUtils::MakeMaker ();
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.61';
+	$VERSION = '0.62';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 
@@ -68,6 +69,15 @@
     );
 }
 
+sub realclean_files {
+    my $self  = shift;
+    my $realclean = $self->makemaker_args->{realclean} ||= {};
+    %$realclean = (
+        %$realclean, 
+        FILES => join(' ', grep length, $realclean->{FILES}, @_),
+    );
+}
+
 sub libs {
     my $self = shift;
     my $libs = ref $_[0] ? shift : [ shift ];
@@ -159,6 +169,15 @@
     $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
     $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
 
+    # Module::Install will never be used to build the Core Perl
+    # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
+    # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
+    $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
+    #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
+
+    # XXX - This is currently unused; not sure if it breaks other MM-users
+    # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
+
     open  MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
     print MAKEFILE  "$preamble$makefile$postamble" or die $!;
     close MAKEFILE  or die $!;
@@ -183,4 +202,4 @@
 
 __END__
 
-#line 312
+#line 331

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Metadata.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Metadata.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Metadata.pm	Tue Apr 11 08:12:51 2006
@@ -1,12 +1,15 @@
 #line 1
 package Module::Install::Metadata;
 
+use strict 'vars';
 use Module::Install::Base;
- at ISA = qw{Module::Install::Base};
-
-$VERSION = '0.61';
 
-use strict 'vars';
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.62';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 my @scalar_keys = qw{
     name module_name abstract author version license
@@ -235,11 +238,13 @@
         ^
         use \s*
         v?
-        ([\d\.]+)
+        ([\d_\.]+)
         \s* ;
     /ixms
       )
     {
+        my $v = $1;
+        $v =~ s{_}{}g;
         $self->perl_version($1);
     }
     else {

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Scripts.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Scripts.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Scripts.pm	Tue Apr 11 08:12:51 2006
@@ -5,10 +5,11 @@
 use Module::Install::Base;
 use File::Basename ();
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.61';
-	@ISA     = qw(Module::Install::Base);
+	$VERSION = '0.62';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
 }
 
 sub prompt_script {

Modified: Locale-Maketext-Lexicon/inc/Module/Install/Win32.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/Win32.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/Win32.pm	Tue Apr 11 08:12:51 2006
@@ -4,9 +4,10 @@
 use strict;
 use Module::Install::Base;
 
-use vars qw{$VERSION @ISA};
+use vars qw{$VERSION $ISCORE @ISA};
 BEGIN {
-	$VERSION = '0.61';
+	$VERSION = '0.62';
+	$ISCORE  = 1;
 	@ISA     = qw{Module::Install::Base};
 }
 

Modified: Locale-Maketext-Lexicon/inc/Module/Install/WriteAll.pm
==============================================================================
--- Locale-Maketext-Lexicon/inc/Module/Install/WriteAll.pm	(original)
+++ Locale-Maketext-Lexicon/inc/Module/Install/WriteAll.pm	Tue Apr 11 08:12:51 2006
@@ -1,12 +1,15 @@
 #line 1
 package Module::Install::WriteAll;
 
+use strict;
 use Module::Install::Base;
- at ISA = qw(Module::Install::Base);
-
-$VERSION = '0.61';
 
-use strict;
+use vars qw{$VERSION $ISCORE @ISA};
+BEGIN {
+	$VERSION = '0.62';
+	$ISCORE  = 1;
+	@ISA     = qw{Module::Install::Base};
+}
 
 sub WriteAll {
     my $self = shift;

Modified: Locale-Maketext-Lexicon/lib/Locale/Maketext/Lexicon.pm
==============================================================================
--- Locale-Maketext-Lexicon/lib/Locale/Maketext/Lexicon.pm	(original)
+++ Locale-Maketext-Lexicon/lib/Locale/Maketext/Lexicon.pm	Tue Apr 11 08:12:51 2006
@@ -1,5 +1,5 @@
 package Locale::Maketext::Lexicon;
-$Locale::Maketext::Lexicon::VERSION = '0.56';
+$Locale::Maketext::Lexicon::VERSION = '0.57';
 
 use strict;
 
@@ -9,8 +9,8 @@
 
 =head1 VERSION
 
-This document describes version 0.56 of Locale::Maketext::Lexicon,
-released April 2, 2006.
+This document describes version 0.57 of Locale::Maketext::Lexicon,
+released April 11, 2006.
 
 =head1 SYNOPSIS
 
@@ -342,14 +342,27 @@
     sub {
         my $lh  = shift;
         my $str = shift;
-        $str =~ s/[\~\[\]]/~$&/g;
-        $str =~ s{(^|[^%\\])%([A-Za-z#*]\w*)\(([^\)]*)\)}
-                {"$1\[$2,"._unescape($3)."]"}eg;
-        $str =~ s/(^|[^%\\])%(\d+|\*)/$1\[_$2]/g;
+        $str =~ s{([\~\[\]])}{~$1}g;
+        $str =~ s{  ([%\\]%)                        # 1 - escaped sequence
+                 |  % 
+                        (?:
+                            ([A-Za-z#*]\w*)         # 2 - function call
+                                \(([^\)]*)\)        # 3 - arguments
+                        |
+                            (\d+|\*)                # 4 - variable
+                        )
+                 }
+                 {$1 ? $1 : $2 ? "\[$2,"._unescape($3)."]" : "[_$4]"}egx;
         return $orig->($lh, $str, @_);
     }
 }
 
+sub _unescape {
+    my $str = shift;
+    $str =~ s/(^|,)%(\d+|\*)(,|$)/$1_$2$3/g;
+    return $str;
+}
+
 sub TIEHASH {
     my ($class, $args) = @_;
     return bless($args, $class);

Added: Locale-Maketext-Lexicon/t/6-gettext.t
==============================================================================
--- (empty file)
+++ Locale-Maketext-Lexicon/t/6-gettext.t	Tue Apr 11 08:12:51 2006
@@ -0,0 +1,235 @@
+#!/usr/bin/perl -w
+use strict;
+use Test::More tests => 30;
+
+package Hello::I18N;
+use Test::More;
+use Tie::Hash;
+
+my $warned;
+$SIG{__WARN__} = sub { $warned++ };
+
+use_ok(base => 'Locale::Maketext');
+use_ok(
+    'Locale::Maketext::Lexicon' => {
+	en	=> ['Auto'],
+	fr	=> ['Tie'	=> [ 'Tie::StdHash' ]],
+	de	=> ['Gettext'	=> \*::DATA],
+	zh_tw	=> ['Gettext'	=> 't/messages.mo'],
+	zh_cn	=> ['Msgcat'	=> 't/gencat.m'],
+	zh_hk   => [
+	    'Msgcat'	=> 't/gencat.m',
+	    'Gettext'   => 't/messages.po',
+	],
+        _style => 'gettext',
+    },
+);
+
+ok(!$warned, 'no warnings on blank lines');
+
+Locale::Maketext::Lexicon->import({
+    de_de => ['Gettext'	=> \*::DATA],
+    _use_fuzzy => 1,
+});
+
+package main;
+
+################################################################
+
+ok(my $lh = Hello::I18N->get_handle('en-us'), 'Auto - get_handle');
+
+is(
+    $lh->maketext('Heute die Welt'),
+    'Heute die Welt',
+    'Auto - autofilling'
+);
+
+################################################################
+
+ok($lh = Hello::I18N->get_handle('de'), 'Gettext - get_handle');
+
+is(
+    $lh->maketext('Hello, World!'),
+    'Hallo, Welt!',
+    'Gettext - simple case'
+);
+is(
+    $lh->maketext('You have %*(%1,piece) of mail.', 10),
+    'Sie haben 10 Poststuecken.',
+    'Gettext - complex case'
+);
+is(
+    $lh->maketext('%1 %2 %*', 1, 2, 3),
+    '123 2 1',
+    'Gettext - asterisk interpolation'
+);
+is(
+    $lh->maketext('%1%2%*', 1, 2, 3),
+    '12321',
+    'Gettext - concatenated variables'
+);
+is(
+    $lh->maketext('%1()', 10),
+    '10()',
+    'Gettext - correct parens'
+);
+is(
+    $lh->maketext('__Content-Type'),
+    'text/plain; charset=ISO-8859-1',
+    'Gettext - metadata'
+);
+is(
+    $lh->maketext('%1()', 10),
+    '10()',
+    'Gettext - correct parens'
+);
+is(
+    $lh->maketext("\n\nKnowledge\nAnd\nNature\n\n"),
+"\n\n".
+"Ich wuenschte recht gelehrt zu werden,\n".
+"Und moechte gern, was auf der Erden\n".
+"Und in dem Himmel ist, erfassen,\n".
+"Die Wissenschaft und die Natur.\n\n",
+    'Gettext - multiline'
+);
+
+is(
+    eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") },
+    undef,
+    'Gettext - fuzzy entries are ignored'
+);
+
+ok($lh = Hello::I18N->get_handle('de_de'), 'Gettext - get_handle on DATA again');
+is(
+    eval { $lh->maketext("The Hitchhiker's Guide to the Galaxy") },
+    'Der Fuehrer des Trampers zur Galaxie',
+    'Gettext - fuzzy entries are recognized with _use_fuzzy'
+);
+
+################################################################
+
+SKIP: {
+    skip("no msgunfmt available", 2) unless `msgunfmt -V` and !$?;
+
+    ok($lh = Hello::I18N->get_handle('zh_tw'), 'Gettext - get_handle');
+
+    is(
+	$lh->maketext('This is a test'),
+	'這是測試',
+	'Gettext - MO File'
+    );
+}
+
+################################################################
+
+ok($lh = Hello::I18N->get_handle('fr'), 'Tie - get_handle');
+$Hello::I18N::fr::Lexicon{"Good morning"} = 'Bon jour';
+$Hello::I18N::fr::Lexicon{"Good morning, [_1]"} = 'Bon jour, [_1]';
+
+is(
+    $lh->maketext('Good morning'),
+    'Bon jour',
+    'Tie - simple case'
+);
+
+is(
+    $lh->maketext('Good morning, %1', 'Sean'),
+    'Bon jour, Sean',
+    'Tie - complex case'
+);
+
+################################################################
+
+ok($lh = Hello::I18N->get_handle('zh_cn'), 'Msgcat - get_handle');
+is(
+    $lh->maketext(1, 1),
+    'First string',
+    'Msgcat - simple case'
+);
+is(
+    $lh->maketext(1, 2),
+    'Second string',
+    'Msgcat - continued string'
+);
+is(
+    $lh->maketext(1, 3),
+    'Third string',
+    'Msgcat - quote character'
+);
+is(
+    $lh->maketext(1, 4),
+    'Fourth string',
+    'Msgcat - quote character + continued string'
+);
+
+################################################################
+
+ok($lh = Hello::I18N->get_handle('zh_hk'), 'Multiple lexicons - get_handle');
+
+is(
+    $lh->maketext(1, 1),
+    'First string',
+    'Multiple lexicons - first'
+);
+
+is(
+    $lh->maketext('This is a test'),
+    '這是測試',
+    'Multiple lexicons - second'
+);
+
+
+__DATA__
+msgid ""
+msgstr ""
+"Project-Id-Version: Test App 0.01\n"
+"POT-Creation-Date: 2002-05-02 11:36+0800\n"
+"PO-Revision-Date: 2002-05-13 02:00+0800\n"
+"Last-Translator: <audreyt at audreyt.org>\n"
+"Language-Team: German <audreyt at audreyt.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: Hello.pm:10
+msgid "Hello, World!"
+msgstr "Hallo, Welt!"
+
+#: Hello.pm:11
+msgid "You have %*(%1,piece) of mail."
+msgstr "Sie haben %*(%1,Poststueck,Poststuecken)."
+
+#: Hello.pm:12
+msgid "%1()"
+msgstr "%1()"
+
+#: Hello.pm:13
+msgid "%1 %2 %*"
+msgstr "%* %2 %1"
+
+#: Hello.pm:14
+msgid "%1%2%*"
+msgstr "%*%2%1"
+
+#: Hello.pm:15
+msgid ""
+"\n"
+"\n"
+"Knowledge\n"
+"And\n"
+"Nature\n"
+"\n"
+msgstr ""
+"\n"
+"\n"
+"Ich wuenschte recht gelehrt zu werden,\n"
+"Und moechte gern, was auf der Erden\n"
+"Und in dem Himmel ist, erfassen,\n"
+"Die Wissenschaft und die Natur.\n"
+"\n"
+
+#: Hello.pm:16
+#, big, furry, fuzzy
+msgid "The Hitchhiker's Guide to the Galaxy"
+msgstr "Der Fuehrer des Trampers zur Galaxie"
+


More information about the Rt-commit mailing list