[Catalyst] patch for Catalyst::Plugin::I18N
Daisuke Murase
typester at cpan.org
Sun Dec 11 10:11:04 CET 2005
Hi.
I tried to use C::P::I18N, and I wonted a function that returns
name of cullently selected locale in my supported list.
Here is brief dirty patch added function named 'language'
example:
When Accept-Language is 'de, en',
but I have only 'en' and 'ja' locale files.
Then $c->language returns 'en'.
--
Daisuke Murase
typester at cpan.org
-------------- next part --------------
Index: Catalyst-Plugin-I18N/I18N.pm
===================================================================
--- Catalyst-Plugin-I18N/I18N.pm (revision 2633)
+++ Catalyst-Plugin-I18N/I18N.pm (working copy)
@@ -102,6 +102,22 @@
return $c->{languages};
}
+=head3 language
+
+return selected locale in your locales list.
+
+=cut
+
+sub language {
+ my $c = shift;
+ my $class = ref $c || $c;
+
+ my $lang = ref "$class\::I18N"->get_handle;
+ $lang =~ s/.*:://;
+
+ return $lang;
+}
+
=head3 loc
=head3 localize
More information about the Catalyst
mailing list