$ ./1.keyboard1.pl title is 1.keyboard path1 is /home/bob/2.scripts/pages/1.keyboard abs is /home/bob/2.scripts/pages/1.keyboard/1.keyboard1.pl variable is переменная переменная is variable ini path is ...internals... object created, back with caller word is 1.keyboard dir2 is perlmonks 1.keyboard1.html 1.keyboard2.html 1.keyboard3.html files are 1.keyboard1.html 1.keyboard2.html 1.keyboard3.html old num is 3 Make rus captions(y/n)?: y matching are a.txt b.txt c.txt rus_munge is /home/bob/2.scripts/pages/1.keyboard/template_stuff/translations/trans.02-11-2018-16-14-09.txt rus_path is /home/bob/2.scripts/pages/1.keyboard/template_stuff/ruscaptions/a.txt rus_path is /home/bob/2.scripts/pages/1.keyboard/template_stuff/ruscaptions/b.txt rus_path is /home/bob/2.scripts/pages/1.keyboard/template_stuff/ruscaptions/c.txt Get other translations(y/n)?: y getting translation from yandex getting translation from bing getting translation from apertium remote_dir is 1.keyboard4 result is 1.keyboard

Vancouver, Fri Nov 2 16:14:53 2018

qwerty: йцукен

dir is /home/bob/2.scripts/pages/1.keyboard/template_stuff/captions dir is /home/bob/2.scripts/pages/1.keyboard/template_stuff/ruscaptions tmpl is /home/bob/2.scripts/pages/1.keyboard/template_stuff/code2.tmpl Put file to server(y/n)?: y server dir is perlmonks mkdir1 failed path3 is /home/bob/2.scripts/pages/1.keyboard/template_stuff/1.keyboard1.css mkdir2 failed /pmimage/1.keyboard4 ... return is 1.keyboard4.html $ $ cat 1.keyboard1.pl #!/usr/bin/perl -w use 5.011; use lib "template_stuff"; use html7; use trans1; use Path::Tiny; use utf8; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; # initializations that must precede main data structure my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny # decode paths my $abs = path(__FILE__)->absolute; my $path1 = Path::Tiny->cwd; my $title = $path1->basename; $abs = decode('UTF-8', $abs); $path1 = decode('UTF-8', $path1); $title = decode('UTF-8', $title); say "title is $title"; say "path1 is $path1"; say "abs is $abs"; my $path2 = path( $path1, $ts ); # page params my %vars = ( title => $title, headline => undef, place => 'Vancouver', base_url => 'http://www.merrillpjensen.com', css_file => "${title}1.css", header => path( $path2, "hc_input2.txt" ), footer => path( $path2, "footer_center3.txt" ), body => path( $path2, "rebus5.tmpl" ), print_script => "1", code_tmpl => path( $path2, "code2.tmpl" ), oitop => path( $path2, "oitop.txt" ), oibottom => path( $path2, "oibottom.txt" ), to_images => path( $path2, $images ), eng_captions => path( $path2, $captions ), rus_captions => path( $path2, $ruscaptions ), translations => path( $path2, 'translations' ), bottom => path( $path2, "bottom1.txt" ), book => 'qwerty: ', chapter => 'йцукен', print_module => 0, script_file => $abs, module_tmpl => path( $path2, "code3.tmpl" ), server_dir => 'perlmonks', image_dir => 'pmimage', ts => 'template_system', css_path => $path2, ); my $variable = "переменная"; say "variable is $variable"; my $переменная = "variable"; say "переменная is $переменная"; my $rvars = \%vars; my $return = create_page( $rvars ); say "return is $return"; __END__ $ cd template_stuff/ $ cat trans1.pm package trans1; require Exporter; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( get_tiny make_russian_captions ); sub make_russian_captions { use 5.011; use warnings; use POSIX qw(strftime); use Path::Tiny; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; my $rvars = shift; my %vars = %$rvars; my $munge = strftime( "%d-%m-%Y-%H-%M-%S\.txt", localtime ); my $in_path = path( $vars{translations}, $munge )->touchpath; my $lang = 'ru'; #system("pwd >$in_path"); works my @matching2; opendir( my $hh, $vars{eng_captions} ) or die "death $!\n"; while ( defined( $_ = readdir($hh) ) ) { if (m/txt$/) { push( @matching2, $_ ); } } #important to sort @matching2 = sort @matching2; say "matching are @matching2"; my $rus_munge = path( $vars{translations}, "trans." . $munge ); say "rus_munge is $rus_munge"; # open file for writing my $fh = path($in_path)->openw_utf8; foreach (@matching2) { my $eng_path = path( $vars{eng_captions}, $_ ); say $fh "##$_##"; my $rus_path = path( $vars{rus_captions}, $_ )->touchpath; say "rus_path is $rus_path"; my $content = path($eng_path)->slurp_utf8; $content =~ s/^\s+|\s+$//g; say $fh "$content"; system("trans :$lang file://$eng_path >$rus_path"); } print "Get other translations(y/n)?: "; my $prompt = ; chomp $prompt; if ( $prompt eq ( "y" | "Y" ) ) { my @translators = qw /yandex bing apertium /; for my $remote (@translators) { my $trans_munge = path( $vars{translations}, "$remote." . $munge ); ## use trans shell say "getting translation from $remote"; system("trans :$lang -e $remote file://$in_path >$trans_munge"); } } return "nothing yet"; } sub get_tiny { ...elided... } 1; $ #### $sftp->mkdir("/$server_dir") or warn "mkdir1 failed $!\n"; $sftp->mkdir("/$image_dir") or warn "mkdir2 failed $!\n"; #### $ trans -S aspell * google deepl bing spell apertium yandex $ #### print "Get other translations(y/n)?: "; my $prompt = ; chomp $prompt; if ( $prompt eq ( "y" | "Y" ) ) { my @translators = qw /yandex bing apertium /; for my $remote (@translators) { my $trans_munge = path( $vars{translations}, "$remote." . $munge ); ## use trans shell say "getting translation from $remote"; system("trans :$lang -e $remote file://$in_path >$trans_munge"); }