line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: PhraseApp (https://phraseapp.com) synchronization plugin for Serge |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Serge::Sync::Plugin::TranslationService::phraseapp; |
4
|
1
|
|
|
1
|
|
15193
|
use parent Serge::Sync::Plugin::Base::TranslationService, Serge::Interface::SysCmdRunner; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1701
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Serge::Util qw(subst_macros); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
9
|
1
|
|
|
1
|
|
434
|
use version; |
|
1
|
|
|
|
|
1955
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = qv('0.900.8'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub name { |
14
|
3
|
|
|
3
|
0
|
31429
|
return 'PhraseApp translation software (https://phraseapp.com) synchronization plugin'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
3
|
|
|
3
|
0
|
40
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
17
|
$self->SUPER::init(@_); |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
22
|
$self->{optimizations} = 1; # set to undef to disable optimizations |
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
|
|
21
|
$self->merge_schema({ |
25
|
|
|
|
|
|
|
config_file => 'STRING', |
26
|
|
|
|
|
|
|
wait_for_uploads => 'BOOLEAN', |
27
|
|
|
|
|
|
|
verbose => 'BOOLEAN' |
28
|
|
|
|
|
|
|
}); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub validate_data { |
32
|
3
|
|
|
3
|
0
|
2319
|
my ($self) = @_; |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
18
|
$self->SUPER::validate_data; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
1252
|
$self->{data}->{config_file} = subst_macros($self->{data}->{config_file}); |
37
|
3
|
|
|
|
|
109
|
$self->{data}->{wait_for_uploads} = subst_macros($self->{data}->{wait_for_uploads}); |
38
|
3
|
|
|
|
|
84
|
$self->{data}->{verbose} = subst_macros($self->{data}->{verbose}); |
39
|
|
|
|
|
|
|
|
40
|
3
|
50
|
|
|
|
79
|
die "'config_file' not defined" unless defined $self->{data}->{config_file}; |
41
|
3
|
100
|
|
|
|
30
|
die "'config_file', which is set to '$self->{data}->{config_file}', does not point to a valid file.\n" unless -f $self->{data}->{config_file}; |
42
|
|
|
|
|
|
|
|
43
|
2
|
100
|
|
|
|
62
|
$self->{data}->{wait_for_uploads} = 1 unless defined $self->{data}->{wait_for_uploads}; |
44
|
2
|
100
|
|
|
|
31
|
$self->{data}->{verbose} = 0 unless defined $self->{data}->{verbose}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub run_phraseapp_cli { |
48
|
4
|
|
|
4
|
0
|
14
|
my ($self, $action, $langs, $capture) = @_; |
49
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
17
|
$ENV{'PHRASEAPP_CONFIG'} = $self->{data}->{config_file}; |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
46
|
my $command = $action; |
53
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
12
|
$command = 'phraseapp '.$command; |
55
|
|
|
|
|
|
|
|
56
|
4
|
100
|
|
|
|
13
|
if ($self->{data}->{verbose}) { |
57
|
2
|
|
|
|
|
17
|
$command .= ' --verbose '; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
4
|
|
|
|
|
146
|
print "Running '$command'...\n"; |
61
|
4
|
|
|
|
|
44
|
return $self->run_cmd($command, $capture); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub pull_ts { |
65
|
2
|
|
|
2
|
0
|
578
|
my ($self, $langs) = @_; |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
7
|
return $self->run_phraseapp_cli('pull', $langs); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub push_ts { |
71
|
2
|
|
|
2
|
0
|
1218
|
my ($self, $langs) = @_; |
72
|
|
|
|
|
|
|
|
73
|
2
|
|
|
|
|
6
|
my $action = 'push'; |
74
|
|
|
|
|
|
|
|
75
|
2
|
100
|
|
|
|
11
|
if ($self->{data}->{wait_for_uploads}) { |
76
|
1
|
|
|
|
|
10
|
$action = $action.' --wait'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
16
|
$self->run_phraseapp_cli($action, $langs); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |