line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Utils::Autotranslator::Interactive; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
4292
|
use strict;
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
43
|
use warnings;
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
536
|
use Encode qw(decode_utf8);
|
|
2
|
|
|
|
|
14453
|
|
|
2
|
|
|
|
|
117
|
|
6
|
2
|
|
|
2
|
|
13
|
use Moo;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
1139
|
use namespace::autoclean;
|
|
2
|
|
|
|
|
13218
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.014';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends qw(
|
12
|
|
|
|
|
|
|
Locale::Utils::Autotranslator
|
13
|
|
|
|
|
|
|
);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub translate_text {
|
16
|
2
|
|
|
2
|
1
|
5
|
my ( $self, $msgid ) = @_;
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
50
|
$self->comment('translated by: interactive');
|
19
|
2
|
|
|
|
|
230
|
() = printf
|
20
|
|
|
|
|
|
|
"\n"
|
21
|
|
|
|
|
|
|
. "\n"
|
22
|
|
|
|
|
|
|
. "========== %s -> %s ==========\n"
|
23
|
|
|
|
|
|
|
. "%s\n"
|
24
|
|
|
|
|
|
|
. "========== paste now, press Enter and D (or line __END__ anywhere) ==========\n",
|
25
|
|
|
|
|
|
|
$self->developer_language,
|
26
|
|
|
|
|
|
|
$self->language,
|
27
|
|
|
|
|
|
|
$msgid;
|
28
|
2
|
|
|
|
|
11
|
my $msgstr = q{};
|
29
|
|
|
|
|
|
|
LOOP: {
|
30
|
2
|
|
|
|
|
5
|
local $_ = ;
|
|
3
|
|
|
|
|
64
|
|
31
|
|
|
|
|
|
|
defined
|
32
|
3
|
100
|
|
|
|
22
|
or last LOOP;
|
33
|
2
|
100
|
|
|
|
22
|
m{\A __END__ }xms
|
34
|
|
|
|
|
|
|
and die $_;
|
35
|
1
|
|
|
|
|
3
|
$msgstr .= $_;
|
36
|
1
|
|
|
|
|
3
|
redo LOOP;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# normally newline count of msgid and msgstr is equal
|
40
|
1
|
|
|
|
|
25
|
my $newline_count_msgid = () = $msgid =~ m{ \x{A} }xmsg;
|
41
|
1
|
|
|
|
|
5
|
my $newline_count_msgstr = () = $msgstr =~ m{ \x{A} }xmsg;
|
42
|
1
|
50
|
|
|
|
24
|
if ($newline_count_msgstr > $newline_count_msgid) {
|
43
|
1
|
|
|
|
|
6
|
chomp $msgstr;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# newlines should be equal to msgid
|
47
|
1
|
|
|
|
|
5
|
my ($newline) = $msgid =~ m{ (\r? \n) }xms;
|
48
|
1
|
|
50
|
|
|
7
|
$newline ||= "\n";
|
49
|
1
|
|
|
|
|
3
|
$msgstr =~ s{\r? \n}{$newline}xmsg;
|
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
11
|
return decode_utf8($msgstr);
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable;
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1;
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__
|