Locale-Maketext-Extract-DBI-0.01/ 40777 0 0 0 10364230243 11431 5Locale-Maketext-Extract-DBI-0.01/bin/ 40777 0 0 0 10364230243 12201 5Locale-Maketext-Extract-DBI-0.01/bin/xgettextdbi100666 0 0 2660 10364223723 14505 =head1 NAME xgettextdbi - Fetch values for translation from a database =head1 SYNOPSIS % xgettextdbi [OPTIONS] INPUT OPTIONS: --dsn the database DSN --username your username --password your password --query the SQL query to select the column you would like translated OUTPUT OPTIONS: -d, --default-domain Use $NAME.po for output, instead of messages.po -o, --output PO file name to be written or incrementally updated (use "-" for STDOUT) -p, --output-dir Output files will be placed in this directory =head1 DESCRIPTION Grabs values from a database; =cut use strict; use warnings; use Locale::Maketext::Extract::DBI; use Getopt::Long; use Pod::Usage; our $VERSION = '0.01'; my %options; GetOptions( \%options, qw( dsn=s username=s password=s query=s help=s p|output-dir=s o|output=s d|default-domain=s ) ); pod2usage( 1 ) && exit if exists $options{ help } or !keys %options; my $extractor = Locale::Maketext::Extract::DBI->new; $extractor->extract( %options ); =head1 AUTHOR =over 4 =item * Brian Cassidy Ebricas@cpan.orgE =back =head1 COPYRIGHT AND LICENSE Copyright 2006 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over 4 =item * L =back =cut Locale-Maketext-Extract-DBI-0.01/Build.PL100666 0 0 1016 10364226104 12741 use strict; use Module::Build; my $build = Module::Build->new( module_name => 'Locale::Maketext::Extract::DBI', dist_author => 'Brian Cassidy ', license => 'perl', create_readme => 1, create_makefile_pl => 'traditional', script_files => [ qw( bin/xgettextdbi ) ], requires => { 'Locale::Maketext::Lexicon' => 0, 'DBI' => 0 }, build_requires => { 'Test::More' => 0, }, ); $build->create_build_script;Locale-Maketext-Extract-DBI-0.01/Changes100666 0 0 164 10364172261 12727 Revision history for Perl extension Locale::Maketext::Extract::DBI. 0.01 Fri Jan 20 2006 - original version; Locale-Maketext-Extract-DBI-0.01/lib/ 40777 0 0 0 10364230243 12177 5Locale-Maketext-Extract-DBI-0.01/lib/Locale/ 40777 0 0 0 10364230243 13376 5Locale-Maketext-Extract-DBI-0.01/lib/Locale/Maketext/ 40777 0 0 0 10364230243 15160 5Locale-Maketext-Extract-DBI-0.01/lib/Locale/Maketext/Extract/ 40777 0 0 0 10364230243 16572 5Locale-Maketext-Extract-DBI-0.01/lib/Locale/Maketext/Extract/DBI.pm100666 0 0 4154 10364224252 17552 package Locale::Maketext::Extract::DBI; use strict; use warnings; use Locale::Maketext::Extract; use DBI; use Cwd; our $VERSION = '0.01'; =head1 NAME Locale::Maketext::Extract::DBI - Extract translation keys from a database =head1 SYNOPSIS my $extractor = Locale::Maketext::Extract::DBI->new; $extract->extract( %options ); =head1 DESCRIPTION This module extracts translation keys from a database table. =head1 METHODS =head2 new( ) Creates a new C instance. =cut sub new { my $class = shift; return bless {}, $class; } =head2 extract( %options ) The main method for extraction. Take a list of options to pass to C and C. =cut sub extract { my $self = shift; my %options = @_; my $extractor = Locale::Maketext::Extract->new; my $output = $options{ o } || ( $options{ d } || 'messages' ) . '.po' ; my $cwd = getcwd; $extractor->read_po( $output ) if -r $output and -s _; $self->extract_dbi( $extractor, %options ); $extractor->compile; chdir( $options{ p } || '.' ); $extractor->write_po( $output ); chdir $cwd; } =head2 extract_dbi( $extractor, %options ) Connects to the database, runs the query and stuffs the results in to the C<$extractor>. =cut sub extract_dbi { my( $self, $extractor, %options ) = @_; my $dbh = DBI->connect( ( map{ $options{ $_ } } qw( dsn username password ) ), { RaiseError => 1 } ); my $query = $options{ query }; my $results = $dbh->selectall_arrayref( $query ); for( 0..@$results - 1 ) { $extractor->add_entry( $results->[ $_ ]->[ 0 ] => [ "dbi:$query", $_ + 1] ); } } =head1 AUTHOR =over 4 =item * Brian Cassidy Ebricas@cpan.orgE =back =head1 COPYRIGHT AND LICENSE Copyright 2006 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over 4 =item * L =back =cut 1;Locale-Maketext-Extract-DBI-0.01/Makefile.PL100666 0 0 1172 10364230243 13421 # Note: this file was auto-generated by Module::Build::Compat version 0.03 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Locale::Maketext::Extract::DBI', 'VERSION_FROM' => 'lib/Locale/Maketext/Extract/DBI.pm', 'PREREQ_PM' => { 'DBI' => '0', 'Locale::Maketext::Lexicon' => '0', 'Test::More' => '0' }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [ 'bin/xgettextdbi' ], 'PL_FILES' => {} ) ; Locale-Maketext-Extract-DBI-0.01/MANIFEST100666 0 0 263 10364230243 12560 bin/xgettextdbi Build.PL Changes lib/Locale/Maketext/Extract/DBI.pm MANIFEST This list of files META.yml t/01-use.t t/98-pod_coverage.t t/99-pod.t Makefile.PL README Locale-Maketext-Extract-DBI-0.01/META.yml100666 0 0 632 10364230243 12700 --- name: Locale-Maketext-Extract-DBI version: 0.01 author: - Brian Cassidy abstract: Extract translation keys from a database license: perl requires: DBI: 0 Locale::Maketext::Lexicon: 0 build_requires: Test::More: 0 provides: Locale::Maketext::Extract::DBI: file: lib/Locale/Maketext/Extract/DBI.pm version: 0.01 generated_by: Module::Build version 0.2611 Locale-Maketext-Extract-DBI-0.01/README100666 0 0 1644 10364230243 12333 NAME Locale::Maketext::Extract::DBI - Extract translation keys from a database SYNOPSIS my $extractor = Locale::Maketext::Extract::DBI->new; $extract->extract( %options ); DESCRIPTION This module extracts translation keys from a database table. METHODS new( ) Creates a new "Locale::Maketext::Extract::DBI" instance. extract( %options ) The main method for extraction. Take a list of options to pass to "Locale::Maketext::Extract" and "extract_dbi". extract_dbi( $extractor, %options ) Connects to the database, runs the query and stuffs the results in to the $extractor. AUTHOR * Brian Cassidy COPYRIGHT AND LICENSE Copyright 2006 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO * Locale::Maketext::Extract Locale-Maketext-Extract-DBI-0.01/t/ 40777 0 0 0 10364230243 11674 5Locale-Maketext-Extract-DBI-0.01/t/01-use.t100666 0 0 166 10364172152 13077 use Test::More tests => 1; use strict; use warnings; BEGIN { use_ok( 'Locale::Maketext::Extract::DBI' ); } Locale-Maketext-Extract-DBI-0.01/t/98-pod_coverage.t100666 0 0 243 10334115567 14760 use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; all_pod_coverage_ok();Locale-Maketext-Extract-DBI-0.01/t/99-pod.t100666 0 0 245 10334115567 13110 use Test::More; use strict; use warnings; eval 'use Test::Pod 1.00'; plan skip_all => 'Test::Pod 1.00 required for testing POD' if $@; all_pod_files_ok();