Object::I18n - Internationalize objects


Object-I18n documentation  | view source Contained in the Object-I18n distribution.

Index


NAME

Top

Object::I18n - Internationalize objects

SYNOPSIS

Top

    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

Top

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

Top

i18n.

AUTHOR

Top

Rick Delaney, <rick@bort.ca>

ACKNOWLEDGEMENTS

Top

To be filled in.

COPYRIGHT AND LICENSE

Top


Object-I18n documentation  | view source Contained in the Object-I18n distribution.