DBD::PO::Text::PO - read or write a PO file entry by entry


DBD-PO documentation  | view source Contained in the DBD-PO distribution.

Index


NAME

Top

DBD::PO::Text::PO - read or write a PO file entry by entry

$Id: PO.pm 412 2009-08-29 08:58:24Z steffenw $

$HeadURL: https://dbd-po.svn.sourceforge.net/svnroot/dbd-po/trunk/DBD-PO/lib/DBD/PO/Text/PO.pm $

VERSION

Top

2.08

SYNOPSIS

Top

write

    use strict;
    use warnings;

    use Carp qw(croak);
    use English qw(-no_match_vars $OS_ERROR);
    require IO::File;
    require DBD::PO::Text::PO;

    my $file_handle = IO::File->new();
    $file_handle->open(
        $file_name,
        '> :encoding(utf-8)',
    ) or croak "Can not open file $file_name: $OS_ERROR;
    my $text_po = DBD::PO::Text::PO->new({
        eol     => "\n",
        charset => 'utf-8',
    });

    # header
    $text_po->write_entry(
        $file_name,
        $file_handle,
        [
            q{},
            'Content-Type: text/plain; charset=utf-8',
        ],
    );

    # line
    $text_po->write_entry(
        $file_name,
        $file_handle,
        [
            'id',
            'text',
        ],
    );

read

    use strict;
    use warnings;

    use Carp qw(croak);
    use English qw(-no_match_vars $OS_ERROR);
    require IO::File;
    require DBD::PO::Text::PO;

    my $file_handle = IO::File->new();
    $file_handle->open(
        $file_name,
        '< :encoding(utf-8)',
    ) or croak "Can not open file $file_name: $OS_ERROR;
    my $text_po = DBD::PO::Text::PO->new({
        eol     => "\n",
        charset => 'utf-8',
    });

    # header
    my $header_array_ref = $text_po->read_entry($file_name, $file_handle);

    # line
    while ( @{ my $array_ref = $text_po->read_entry($file_name, $file_handle) } ) {
        print "id: $array_ref->[0], text: $array_ref->[1]\n";
    }

DESCRIPTION

Top

The DBD::PO::Text::PO was written as wrapper between DBD::PO and DBD::PO::Locale::PO.

Do not use this module without DBD::PO!

     ---------------------
    |         DBI         |
     ---------------------
               |
     ---------------------     -----------     ---------------
    |       DBD::PO       |---| DBD::File |---| SQL-Statement |
     ---------------------     -----------     ---------------
               |
     ---------------------
    |  DBD::PO::Text::PO  |
     ---------------------
               |
     ---------------------
    | DBD::PO::Locale::PO |
     ---------------------
               |
         table_file.po

SUBROUTINES/METHODS

Top

init

    DBD::PO::Text::PO->init(...);

This is a class method to optimize the size of arrays. The default settings are performant.

Do not call this method during you have an active object!

Parameters:

* :plural

Allow all plural forms.

* :previous

Allow all previus forms.

* :format

Allow all format flags.

* :all

Allow all.

* c-format as example

Allow the format flag 'c-format'. For all the other format flags see DBD::PO::Locale::PO.

method new

method write_entry

method read_entry

DIAGNOSTICS

Top

none

CONFIGURATION AND ENVIRONMENT

Top

none

DEPENDENCIES

Top

Carp

English

Params::Validate

DBD::PO::Locale::PO

Socket

Set::Scalar

INCOMPATIBILITIES

Top

not known

BUGS AND LIMITATIONS

Top

not known

SEE ALSO

Top

DBD::File

AUTHOR

Top

Steffen Winkler

LICENSE AND COPYRIGHT

Top


DBD-PO documentation  | view source Contained in the DBD-PO distribution.