Update of /cvsroot/openinteract/OpenInteract2/doc/Manual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24735/Manual
Modified Files:
I18N.pod
Log Message:
get rid of 'language.custom_language_id_class' and show howto do it with an observer
Index: I18N.pod
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract2/doc/Manual/I18N.pod,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** I18N.pod 26 Feb 2004 02:42:50 -0000 1.11
--- I18N.pod 25 Feb 2005 05:40:17 -0000 1.12
***************
*** 78,94 ****
We also provide the means for you to step in and implement your own --
! you could parse it from the URL, use L<Geo::IP>, whatever. Just
! declare your class in the server configuration key
! 'language.custom_language_id_class':
!
! [language]
! ...
! custom_language_id_class = MyApp::I18N::LanguageId
!
! And implement the class method 'identify_languages()', which takes a
! single argument of the languages identified so far. Here's a naive
! example:
! package MyApp::I18N::LanguageId;
use Geo::IP;
--- 78,87 ----
We also provide the means for you to step in and implement your own --
! you could parse it from the URL, use L<Geo::IP>, whatever. Just create
! an observer for the controller (under
! L<OpenInteract2::Observer::Controller>) and wait for the 'action
! assigned' observation which occurs every request:
! package OpenInteract2::Observer::Controller::LanguageId;
use Geo::IP;
***************
*** 97,111 ****
my $gi = Geo::IP->new( GEOIP_STANDARD );
! sub identify_languages {
! my ( $class, @oi_langs ) = @_;
! my $country = $gi->country_code_by_addr( CTX->request->remote_host );
! my @langs_from_country = $class->_some_nifty_method( $country )
! push @oi_langs, @langs_from_country;
! return @oi_langs;
! }
! Note that if you return a list with entries it B<replaces> what OI has
! so far identified. We took care of this above by first copying all the
! languages previously identified then adding to them with the C<push>.
=head1 SETTING UP LOCALIZAION IN YOUR PACKAGE
--- 90,105 ----
my $gi = Geo::IP->new( GEOIP_STANDARD );
! sub update {
! my ( $class, $controller, $type, $action ) = @_;
! return unless ( $type eq 'action assigned' );
! my $request = CTX->request;
! # get our new languages...
! my $country = $gi->country_code_by_addr( $request->remote_host );
! my @langs_from_country = $class->_some_nifty_method( $country );
!
! # assign the new languages after the existing ones
! $request->assign_languages( $request->language(), @langs_from_country );
! }
=head1 SETTING UP LOCALIZAION IN YOUR PACKAGE
|