Rick Delaney > Object-I18n > Object::I18n

Download:
Object-I18n-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.02   Source  

NAME ^

Object::I18n - Internationalize objects

SYNOPSIS ^

    package Greeting;
    sub new { my $x = $_[1]; bless \$x; }
    sub greeting { @_ ? ${$_[1]} : (${$_[1]} = $_[2]) }
    use Object::I18n qw(id);
    __PACKAGE__->i18n->storage('Greeting::CDBI::I18n');
    __PACKAGE__->i18n->register('greeting');
    
    package main;
    my $obj = Greeting->new("Hello, world\n");
    print $obj->greeting;# "Hello, world\n"
    $obj->i18n->language('fr');
    print $obj->greeting;# exception
    $obj->greeting("Bonjour, monde\n");
    print $obj->greeting;# "Bonjour, monde\n"

DESCRIPTION ^

Object::I18n overrides methods in your class to return international content. It provides one mixin method, i18n(), which returns an Object::I18n object. The object returned is different depending on whether you call it on your class or an instance of your class. See "METHODS" below.

METHODS

Most methods can be either class methods or object methods but this doesn't mean what you may be accustomed to. A method is considered to act as a class method if it is called on an Object::I18n object returned from the class form of the i18n() method. It acts as an object method when called on the object returned from the object form of the i18n() method.

language [LANGUAGE]

Returns and optionally sets the current language. If called as a class method it affects all instances of a class, except those that have set language() for themselves. If unset, methods should behave as if Object::I18n was not being used at all.

register METHODLIST

Registers the list of method names as i14able. The methods will be overridden so that they return i14ed content when language is set.

storage_class [CLASS]

Returns and optionally set the class that controls how translations are stored.

inject OPTIONS

Injects a new translation into your storage_class. The options are:

language

The language the translation is in. If not set then the language returned by the language() method will be used.

attr

The attribute (method) in your class that the translation is for.

data

The actual translated text to be stored.

notes

Any notes to be saved along with the translation. Requires you to have configured a history_class.

EXPORT ^

i18n.

AUTHOR ^

Rick Delaney, <rick@bort.ca>

ACKNOWLEDGEMENTS ^

To be filled in.

COPYRIGHT AND LICENSE ^

Copyright (C) 2005 by Rick Delaney

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.