NAME

DBIx::Class::I18NColumns - Internationalization for DBIx::Class Result class

VERSION

Version 0.01

SYNOPSIS

package MySchema::Result::Song;

use strict;
use warnings;
use parent 'DBIx::Class';

__PACKAGE__->load_components( qw/ I18NColumns ForceUTF8 Core / );

__PACKAGE__->table( 'song' );
__PACKAGE__->add_columns(
    'id',
    { data_type => 'INT', default_value => 0, is_nullable => 0 },
    'author',
    { data_type => 'VARCHAR', default_value => "", is_nullable => 0, size => 255 },
);
__PACKAGE__->add_i18n_columns(
    'title',
    { data_type => 'VARCHAR', default_value => "", is_nullable => 0, size => 255 },
    'lyrics',
    { data_type => 'TEXT', default_value => "", is_nullable => 0 },
);

__PACKAGE__->set_primary_key( 'id' );

1;

# then, you have an auto generated resultset where title and lyrics are stored
# in different languages:

my $song = $myschema->resultset( 'Song' )->create({
    author   => 'Flopa',
    title    => 'Germinar',
    lyrics   => 'La vida se toma como el vino pura, y ...',
    language => 'es',
});

print $song->title; # prints 'Germinar'

$song->language('en');
$song->title('To germinate');      # set title in english
$song->lyrics('traslated lyrics'); # set lyrics in english
$song->update;                     # store title and lyrics

print $song->title;         # prints 'To Germinate'
print $song->title(['es']); # prints 'Germinar'
$song->language('es');
print $song->title;         # prints 'Germinar'

add_i18n_columns

Create internationalizable columns. The columns are created in the same 
way you do with in L<add_columns|DBIx::Class::ResultSource/add_columns>.

Only text and varchar columns can be user. If you don't specify the data_type,
varchar will be used by default.

schema_class

i18n_resultset

auto_i18n_rs

By default, this component will autocreate the result class that will be used to store internationalized values. You should overwrite this method to stop this component to do this and then you must create is manually.

In your result class that use this component:

sub auto_i18n_rs { 0 }

language_column

The name for the language column to be used and autocreated. Defaults on 'language'.

foreign_column

The name for the column to store the PK of the internationalized result class. Defaults on id_[table name of result source]

has_any_column

Returns true if the source has a i18n or regular column of this name, false otherwise.

has_i18n_column

Returns true if the source has a i18n column of this name, false otherwise.

set_column

Overloaded "set_column" in DBIx::Class::Row to manage i18n columns cleanly.

store_column

Overloaded "store_column" in DBIx::Class::Row to manage i18n columns cleanly.

get_column

Overloaded "get_column" in DBIx::Class::Row to manage i18n columns cleanly.

update

Overloaded "update" in DBIx::Class::Row to manage i18n columns cleanly.

AUTHOR

Diego Kuperman, <diego at freekeylabs.com >

BUGS

Please report any bugs or feature requests to bug-dbix-class-i18ncolumns at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBIx-Class-I18NColumns. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc DBIx::Class::I18NColumns

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2010 Diego Kuperman.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.