#!/usr/bin/perl -w

package pere_trans;

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::Util qw(
	trans
);

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

	my $cfg = Lingua::Pere::Config->new('pere-trans.config');

	my $prg = Lingua::Pere::ProgressLine->new(sprintf("Translate '%s'", $cfg->txt), 8);
	trans(
		$cfg->txt,
		$cfg->res,
		sub { $prg->go },
		$cfg->pfx,
		$cfg->mem,
		$cfg->enc,
		$cfg->cas,
		$cfg->lin
	);
	$prg->ok;
}

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

=head1 NAME

pere-trans - translate some types of documents

=head1 SYNOPSIS

pere-trans [options ...]

	Options:
		-help     brief help message
		-man      full documentation
		-txt      source text
		-res      translated text
		-pfx      translator database location
		-enc      charset encoding
		-iln      input language
		-oln      output language
		-thm      thematic dictionary
		-cas      case sensitive
		-lin      paragraph as single line
		-mem      cache mem size
		-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<-txt>

Filename for source document

=item B<-res>

Filename for translated document

=item B<-pfx>

Directory for translator database

=item B<-cas>

Use case sensitive mode

=item B<-enc>

Optional charset encoding for input document.
By default used C<UTF-8>

=item B<-lin>

Means paragraph as single line only for C<Plain Text> documents

=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<-cfg>

Enables to specify other file of a configuration

=back

=head1 DESCRIPTION

B<This script> used for translate some types of documents:

=over 2

=item B<*.rtf>

Rich Text Format File

=item B<*.xml>

DocBook Document

=item B<*.xml>

Microsoft Excel 2003 XML

=item B<*.xml>

Microsoft Word 2003 XML

=item B<*.xhtml, *.xht>

Extensible HyperText Markup Language File

=item B<*.html, *.htm>

Hypertext Markup Language

=item B<*.txt, *.text, *.asc>

Text File

=item B<*.odg>

OpenOffice.org (Ver 2) OpenDocument Graphics Document

=item B<*.otg>

OpenOffice.org (Ver 2) OpenDocument Graphics Document Template

=item B<*.odp>

OpenOffice.org (Ver 2) OpenDocument Presentation

=item B<*.otp>

OpenOffice.org (Ver 2) OpenDocument Presentation Template

=item B<*.ods>

OpenOffice.org (Ver 2) OpenDocument Spreadsheet

=item B<*.ots>

OpenOffice.org (Ver 2) OpenDocument Spreadsheet Template

=item B<*.odt>

OpenOffice.org (Ver 2) OpenDocument Text Document

=item B<*.odm>

OpenOffice.org (Ver 2) OpenDocument Global Text Document

=item B<*.ott>

OpenOffice.org (Ver 2) OpenDocument Text Document Template

=item B<*.oth>

OpenOffice.org (Ver 2) OpenDocument HTML Text Template

=item B<*.sxc>

OpenOffice.org (Ver 1) Spreadsheet

=item B<*.stc>

OpenOffice.org (Ver 1) Spreadsheet Template

=item B<*.sxd>

OpenOffice.org (Ver 1) Draw File

=item B<*.std>

OpenOffice.org (Ver 1) Drawing Template

=item B<*.sxi>

OpenOffice.org (Ver 1) Presentation File

=item B<*.sti>

OpenOffice.org (Ver 1) Presentation Template

=item B<*.sxw>

OpenOffice.org (Ver 1) Text Document

=item B<*.sxg>

OpenOffice.org (Ver 1) Master Document

=item B<*.stw>

OpenOffice.org (Ver 1) Text Document Template

=back

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
