[Catalyst-commits] r10827 - in Catalyst-Plugin-I18N/trunk: .
lib/Catalyst/Plugin t t/lib/TestApp/I18N
tonvoon at dev.catalyst.perl.org
tonvoon at dev.catalyst.perl.org
Wed Jul 8 09:10:01 GMT 2009
Author: tonvoon
Date: 2009-07-08 09:10:00 +0000 (Wed, 08 Jul 2009)
New Revision: 10827
Added:
Catalyst-Plugin-I18N/trunk/t/lib/TestApp/I18N/i_default.po
Modified:
Catalyst-Plugin-I18N/trunk/Changes
Catalyst-Plugin-I18N/trunk/Makefile.PL
Catalyst-Plugin-I18N/trunk/lib/Catalyst/Plugin/I18N.pm
Catalyst-Plugin-I18N/trunk/t/04live.t
Log:
Add dependency and tests for i-default fallback feature in Locale::Maketext::Simple 0.19
Modified: Catalyst-Plugin-I18N/trunk/Changes
===================================================================
--- Catalyst-Plugin-I18N/trunk/Changes 2009-07-07 21:54:46 UTC (rev 10826)
+++ Catalyst-Plugin-I18N/trunk/Changes 2009-07-08 09:10:00 UTC (rev 10827)
@@ -1,6 +1,7 @@
Revision history for Perl extension Catalyst::Plugin::I18N.
- Add Language List feature by Ton Voon
+ - Add dependency and tests for i-default fallback feature in Locale::Maketext::Simple 0.19
0.09 Sat Apr 18 2009
- switch NEXT out for MRO::Compat
Modified: Catalyst-Plugin-I18N/trunk/Makefile.PL
===================================================================
--- Catalyst-Plugin-I18N/trunk/Makefile.PL 2009-07-07 21:54:46 UTC (rev 10826)
+++ Catalyst-Plugin-I18N/trunk/Makefile.PL 2009-07-08 09:10:00 UTC (rev 10827)
@@ -10,7 +10,7 @@
all_from 'lib/Catalyst/Plugin/I18N.pm';
requires 'Catalyst::Runtime';
-requires 'Locale::Maketext::Simple';
+requires 'Locale::Maketext::Simple' => "0.19";
requires 'I18N::LangTags' => '0.35';
requires 'Locale::Maketext::Lexicon';
requires 'MRO::Compat' => '0.10';
Modified: Catalyst-Plugin-I18N/trunk/lib/Catalyst/Plugin/I18N.pm
===================================================================
--- Catalyst-Plugin-I18N/trunk/lib/Catalyst/Plugin/I18N.pm 2009-07-07 21:54:46 UTC (rev 10826)
+++ Catalyst-Plugin-I18N/trunk/lib/Catalyst/Plugin/I18N.pm 2009-07-08 09:10:00 UTC (rev 10827)
@@ -34,6 +34,7 @@
[% l('Hello Catalyst') %]
[% l('Hello [_1]', 'Catalyst') %]
[% l('lalala[_1]lalala[_2]', ['test', 'foo']) %]
+ [% l('messages.hello.catalyst') %]
=head1 DESCRIPTION
@@ -44,7 +45,11 @@
msgid "Hello Catalyst"
msgstr "Hallo Katalysator"
- #MyApp/I18N/de.pm
+ # MyApp/I18N/i_default.po
+ msgid "messages.hello.catalyst"
+ msgstr "Hello Catalyst - fallback translation"
+
+ # MyApp/I18N/de.pm
package MyApp::I18N::de;
use base 'MyApp::I18N';
our %Lexicon = ( 'Hello Catalyst' => 'Hallo Katalysator' );
@@ -64,6 +69,10 @@
}
);
+All languages fallback to MyApp::I18N which is mapped onto the i-default
+language tag. If you use arbitrary message keys, use i_default.po to translate
+into English, otherwise the message key itself is returned.
+
=head2 EXTENDED METHODS
=head3 setup
Modified: Catalyst-Plugin-I18N/trunk/t/04live.t
===================================================================
--- Catalyst-Plugin-I18N/trunk/t/04live.t 2009-07-07 21:54:46 UTC (rev 10826)
+++ Catalyst-Plugin-I18N/trunk/t/04live.t 2009-07-08 09:10:00 UTC (rev 10827)
@@ -6,7 +6,7 @@
use FindBin;
use lib "$FindBin::Bin/lib";
-use Test::More tests => 28;
+use Test::More tests => 36;
use Catalyst::Test 'TestApp';
BEGIN {
@@ -129,4 +129,33 @@
is( $response->content, $expected, 'Content OK' );
}
+ # test fallback to i_default
+ {
+ my $expected = 'Hello - default';
+ my $request =
+ HTTP::Request->new( GET => 'http://localhost:3000/maketext/messages.hello' );
+
+ $request->header( 'Accept-Language' => 'fr-ca' );
+
+ ok( my $response = request($request), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->code, 200, 'Response Code' );
+
+ is( $response->content, $expected, 'Content OK' );
+ }
+
+ # test AUTO in i_default
+ {
+ my $expected = 'no.key';
+ my $request =
+ HTTP::Request->new( GET => 'http://localhost:3000/maketext/no.key' );
+
+ $request->header( 'Accept-Language' => 'fr-ca' );
+
+ ok( my $response = request($request), 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->code, 200, 'Response Code' );
+
+ is( $response->content, $expected, 'Content OK' );
+ }
}
Added: Catalyst-Plugin-I18N/trunk/t/lib/TestApp/I18N/i_default.po
===================================================================
--- Catalyst-Plugin-I18N/trunk/t/lib/TestApp/I18N/i_default.po (rev 0)
+++ Catalyst-Plugin-I18N/trunk/t/lib/TestApp/I18N/i_default.po 2009-07-08 09:10:00 UTC (rev 10827)
@@ -0,0 +1,2 @@
+msgid "messages.hello"
+msgstr "Hello - default"
More information about the Catalyst-commits
mailing list