line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::Utils::Autotranslator::Interactive; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
5431
|
use strict;
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
64
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
66
|
|
5
|
2
|
|
|
2
|
|
504
|
use Encode qw(decode_utf8);
|
|
2
|
|
|
|
|
13960
|
|
|
2
|
|
|
|
|
134
|
|
6
|
2
|
|
|
2
|
|
15
|
use Moo;
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
15
|
|
7
|
2
|
|
|
2
|
|
1154
|
use namespace::autoclean;
|
|
2
|
|
|
|
|
13020
|
|
|
2
|
|
|
|
|
76
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.014';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends qw(
|
12
|
|
|
|
|
|
|
Locale::Utils::Autotranslator
|
13
|
|
|
|
|
|
|
);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub translate_text {
|
16
|
2
|
|
|
2
|
1
|
6
|
my ( $self, $msgid ) = @_;
|
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
57
|
$self->comment('translated by: interactive');
|
19
|
2
|
|
|
|
|
194
|
() = 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
|
|
|
|
|
10
|
my $msgstr = q{};
|
29
|
|
|
|
|
|
|
LOOP: {
|
30
|
2
|
|
|
|
|
4
|
local $_ = ;
|
|
3
|
|
|
|
|
74
|
|
31
|
|
|
|
|
|
|
defined
|
32
|
3
|
100
|
|
|
|
20
|
or last LOOP;
|
33
|
2
|
100
|
|
|
|
19
|
m{\A __END__ }xms
|
34
|
|
|
|
|
|
|
and die $_;
|
35
|
1
|
|
|
|
|
3
|
$msgstr .= $_;
|
36
|
1
|
|
|
|
|
4
|
redo LOOP;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# normally newline count of msgid and msgstr is equal
|
40
|
1
|
|
|
|
|
26
|
my $newline_count_msgid = () = $msgid =~ m{ \x{A} }xmsg;
|
41
|
1
|
|
|
|
|
5
|
my $newline_count_msgstr = () = $msgstr =~ m{ \x{A} }xmsg;
|
42
|
1
|
50
|
|
|
|
20
|
if ($newline_count_msgstr > $newline_count_msgid) {
|
43
|
1
|
|
|
|
|
4
|
chomp $msgstr;
|
44
|
|
|
|
|
|
|
}
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# newlines should be equal to msgid
|
47
|
1
|
|
|
|
|
4
|
my ($newline) = $msgid =~ m{ (\r? \n) }xms;
|
48
|
1
|
|
50
|
|
|
15
|
$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__
|