From: Chris Williams Date: Fri, 11 Sep 2009 11:14:21 +0000 (+0100) Subject: Updated Locale-Maketext-Simple to CPAN version 0.21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ffd1a11dbdc72439ae1ddf3a36ee639db4a76f82;p=p5sagit%2Fp5-mst-13.2.git Updated Locale-Maketext-Simple to CPAN version 0.21 --- diff --git a/MANIFEST b/MANIFEST index 68a9572..06240ed 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1613,6 +1613,13 @@ ext/List-Util/XS.pp List::Util ext/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm Locale::Simple ext/Locale-Maketext-Simple/t/0-signature.t Locale::Simple tests ext/Locale-Maketext-Simple/t/1-basic.t Locale::Simple tests +ext/Locale-Maketext-Simple/t/2-load_po_without_i_default.t Locale::Simple tests +ext/Locale-Maketext-Simple/t/3-load_po_with_i_default.t Locale::Simple tests +ext/Locale-Maketext-Simple/t/po_with_i_default/en.po Locale::Simple tests +ext/Locale-Maketext-Simple/t/po_with_i_default/fr.po Locale::Simple tests +ext/Locale-Maketext-Simple/t/po_with_i_default/i_default.po Locale::Simple tests +ext/Locale-Maketext-Simple/t/po_without_i_default/en.po Locale::Simple tests +ext/Locale-Maketext-Simple/t/po_without_i_default/fr.po Locale::Simple tests ext/Log-Message/lib/Log/Message/Config.pm Log::Message ext/Log-Message/lib/Log/Message/Handlers.pm Log::Message ext/Log-Message/lib/Log/Message/Item.pm Log::Message diff --git a/ext/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm b/ext/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm index ddc1c65..30760f3 100644 --- a/ext/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm +++ b/ext/Locale-Maketext-Simple/lib/Locale/Maketext/Simple.pm @@ -1,8 +1,8 @@ package Locale::Maketext::Simple; -$Locale::Maketext::Simple::VERSION = '0.18'; +$Locale::Maketext::Simple::VERSION = '0.21'; use strict; -use 5.004; +use 5.005; =head1 NAME @@ -46,6 +46,10 @@ This module is a simple wrapper around B, designed to alleviate the need of creating I for module authors. +The language used is chosen from the loc_lang call. If a lookup is not +possible, the i-default language will be used. If the lookup is not in the +i-default language, then the key will be returned. + If B is not present, it implements a minimal localization function by simply interpolating C<[_1]> with the first argument, C<[_2]> with the second, etc. Interpolated @@ -146,19 +150,19 @@ sub load_loc { eval " package $pkg; use base 'Locale::Maketext'; - %${pkg}::Lexicon = ( '_AUTO' => 1 ); Locale::Maketext::Lexicon->import({ 'i-default' => [ 'Auto' ], '*' => [ Gettext => \$pattern ], _decode => \$decode, _encoding => \$encoding, }); + *${pkg}::Lexicon = \\%${pkg}::i_default::Lexicon; *tense = sub { \$_[1] . ((\$_[2] eq 'present') ? 'ing' : 'ed') } unless defined &tense; 1; " or die $@; - + my $lh = eval { $pkg->get_handle } or return; my $style = lc($args{Style}); if ($style eq 'maketext') { @@ -193,7 +197,6 @@ sub load_loc { return $Loc{$pkg}, sub { $lh = $pkg->get_handle(@_); - $lh = $pkg->get_handle(@_); }; } @@ -205,7 +208,7 @@ sub default_loc { my $str = shift; $str =~ s{((? "$Bin/po_without_i_default", + Style => "gettext", +); + +eval { + require Locale::Maketext::Lexicon; + die unless Locale::Maketext::Lexicon->VERSION(0.20); + require File::Spec; +}; +if ($@) { + plan skip_all => 'No soft dependencies, i_default will not work'; + exit 0; +} + +plan tests => 5; + +loc_lang("en"); +is(loc("Not a lexicon key"), "Not a lexicon key", "Not a lexicon key"); +is(loc("I have got %1 alerts", 65), "I have got 65 alerts", "Got auto key" ); +is(loc("I have acknowledged %1 alerts", 83), "Yo dude, I've been working on these 83 alerts", "Got translation"); + +loc_lang("fr"); +is(loc("system.messages.arbitrary.unique.lexicon.key"), "system.messages.arbitrary.unique.lexicon.key", "No translation" ); +is(loc("I have got %1 alerts", "red"), "Mon Francais red, c'est terrible", "French translated" ); + diff --git a/ext/Locale-Maketext-Simple/t/3-load_po_with_i_default.t b/ext/Locale-Maketext-Simple/t/3-load_po_with_i_default.t new file mode 100755 index 0000000..a880710 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/3-load_po_with_i_default.t @@ -0,0 +1,31 @@ +use strict; +use Test::More; +use FindBin qw($Bin); + +use Locale::Maketext::Simple ( + Path => "$Bin/po_with_i_default", + Style => "gettext", +); + +eval { + require Locale::Maketext::Lexicon; + die unless Locale::Maketext::Lexicon->VERSION(0.20); + require File::Spec; +}; +if ($@) { + plan skip_all => 'No soft dependencies, i_default will not work'; + exit 0; +} + +plan tests => 6; + +loc_lang("en"); +is(loc("Not a lexicon key"), "Not a lexicon key", "Not a lexicon key"); +is(loc("I have got %1 alerts", "hot"), "Maybe it's because I'm a hot Londoner, that I love London tawn", "Got auto key" ); +is(loc("I have acknowledged %1 alerts", 83), "Yo dude, I've been working on these 83 alerts", "Got translation still in en"); +is(loc("system.messages.arbitrary.unique.lexicon.key"), "This is the default message", "Used i_default because not set in en"); + +loc_lang("fr"); +is(loc("system.messages.arbitrary.unique.lexicon.key"), "This is the default message", "Translated from i_default"); +is(loc("I have got %1 alerts", "red"), "Mon Francais red, c'est terrible", "French translated" ); + diff --git a/ext/Locale-Maketext-Simple/t/po_with_i_default/en.po b/ext/Locale-Maketext-Simple/t/po_with_i_default/en.po new file mode 100644 index 0000000..0d80b92 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/po_with_i_default/en.po @@ -0,0 +1,30 @@ +# Locale Maketext Simple language translations +# Copyright (C) All Perl Hackers everywhere +# Ton Voon , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: Locale Maketext Simple\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-06-09 14:10+0000\n" +"Last-Translator: Ton Voon \n" +"Language-Team: English \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. $alerts +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have got %1 alerts" +msgstr "" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have acknowledged %1 alerts" +msgstr "Yo dude, I've been working on these %1 alerts" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "system.messages.arbitrary.unique.lexicon.key" +msgstr "" + diff --git a/ext/Locale-Maketext-Simple/t/po_with_i_default/fr.po b/ext/Locale-Maketext-Simple/t/po_with_i_default/fr.po new file mode 100644 index 0000000..8ecfbf7 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/po_with_i_default/fr.po @@ -0,0 +1,30 @@ +# Locale Maketext Simple language translations +# Copyright (C) All Perl Hackers everywhere +# Ton Voon , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: Locale Maketext Simple\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-06-09 14:10+0000\n" +"Last-Translator: Ton Voon \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. $alerts +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have got %1 alerts" +msgstr "Mon Francais %1, c'est terrible" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have acknowledged %1 alerts" +msgstr "" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "system.messages.arbitrary.unique.lexicon.key" +msgstr "" + diff --git a/ext/Locale-Maketext-Simple/t/po_with_i_default/i_default.po b/ext/Locale-Maketext-Simple/t/po_with_i_default/i_default.po new file mode 100644 index 0000000..7327298 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/po_with_i_default/i_default.po @@ -0,0 +1,30 @@ +# Locale Maketext Simple language translations +# Copyright (C) All Perl Hackers everywhere +# Ton Voon , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: Locale Maketext Simple\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-06-09 14:10+0000\n" +"Last-Translator: Ton Voon \n" +"Language-Team: English \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. $alerts +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have got %1 alerts" +msgstr "Maybe it's because I'm a %1 Londoner, that I love London tawn" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have acknowledged %1 alerts" +msgstr "In idefault instead of en" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "system.messages.arbitrary.unique.lexicon.key" +msgstr "This is the default message" + diff --git a/ext/Locale-Maketext-Simple/t/po_without_i_default/en.po b/ext/Locale-Maketext-Simple/t/po_without_i_default/en.po new file mode 100644 index 0000000..0d80b92 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/po_without_i_default/en.po @@ -0,0 +1,30 @@ +# Locale Maketext Simple language translations +# Copyright (C) All Perl Hackers everywhere +# Ton Voon , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: Locale Maketext Simple\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-06-09 14:10+0000\n" +"Last-Translator: Ton Voon \n" +"Language-Team: English \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. $alerts +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have got %1 alerts" +msgstr "" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have acknowledged %1 alerts" +msgstr "Yo dude, I've been working on these %1 alerts" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "system.messages.arbitrary.unique.lexicon.key" +msgstr "" + diff --git a/ext/Locale-Maketext-Simple/t/po_without_i_default/fr.po b/ext/Locale-Maketext-Simple/t/po_without_i_default/fr.po new file mode 100644 index 0000000..8ecfbf7 --- /dev/null +++ b/ext/Locale-Maketext-Simple/t/po_without_i_default/fr.po @@ -0,0 +1,30 @@ +# Locale Maketext Simple language translations +# Copyright (C) All Perl Hackers everywhere +# Ton Voon , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: Locale Maketext Simple\n" +"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-06-09 14:10+0000\n" +"Last-Translator: Ton Voon \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. $alerts +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have got %1 alerts" +msgstr "Mon Francais %1, c'est terrible" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "I have acknowledged %1 alerts" +msgstr "" + +#. $acknowledged +#: lib/Opsview/Web/Controller/Root.pm:492 +msgid "system.messages.arbitrary.unique.lexicon.key" +msgstr "" +