#!/usr/bin/perl -w

package pere_dmp2dic;

use vars qw($VERSION);
$VERSION = "0.2.0";

use warnings 'all';
use locale;
use strict;
use POSIX;
use Lingua::Pere::Config;
use Lingua::Pere::ProgressLine;
use Lingua::Pere::Dict::Trans;

#**************************************************************************
sub doit {
	$| = 1;

	my $cfg = Lingua::Pere::Config->new('pere-trans.config');
	my $dic = Lingua::Pere::Dict::Trans->new($cfg->pfx, $cfg->ovr, $cfg->mem);
	my $prg = Lingua::Pere::ProgressLine->new(sprintf("Import from '%s'", $cfg->csv), 12);

	$dic->dmp2dic($cfg->csv, sub { $prg->go });
	$prg->ok;
}

#**************************************************************************
&doit;
exit(0);
#**************************************************************************
__END__

=head1 NAME

pere-dmp2dic - import dictionaries into translator's database

=head1 SYNOPSIS

pere-dmp2dic [options ...]

	Options:
		-help     brief help message
		-man      full documentation
		-csv      source text
		-pfx      translator database location
		-iln      input language
		-oln      output language
		-thm      thematic dictionary
		-mem      cache mem size
		-ovr      create new translator database
		-cfg      configuration file

=head1 OPTIONS

=over 2

=item B<-help>

Print a brief help message and exits.

=item B<-man>

Prints the manual page and exits.

=item B<-csv>

Filename for source text in C<Comma Separated Value> format.

=item B<-pfx>

Directory for translator database

=item B<-iln>

Code for input language

Example:

=over 2

=item C<uk-ua> for Ukrainian

=item C<ru-ru> for Russian

=item C<en-us> for American English

It is used together with options C<oln> and C<thm> if option C<pfx> is not set.
As a result value of option C<pfx> undertakes from a configuration file.

=back

=item B<-oln>

Code for output language

Example:

=over 2

=item C<uk-ua> for Ukrainian

=item C<ru-ru> for Russian

=item C<en-us> for American English

It is used together with options C<iln> and C<thm> if option C<pfx> is not set.
As a result value of option C<pfx> undertakes from a configuration file.

=back

=item B<-thm>

Name of the thematic dictionary

It is used together with options C<iln> and C<oln> if option C<pfx> is not set.
As a result value of option C<pfx> undertakes from a configuration file.

=item B<-mem>

Set the size of memory cache in megabytes, otherwise are used system defaults.

=item B<-ovr>

Create new or overwrite existing translation database

=item B<-cfg>

Enables to specify other file of a configuration

=back

=head1 DESCRIPTION

B<This script> used for import source dictionaries into translator's database.

Above options may be found in C<pere-trans.config> file at directories:

=over 2

=item 'B</etc>' - System configuration

=item 'B<~>'    - User's home

=item 'B<.>'    - Current working directory

=back

=cut
