« lib/Serge/Engine/Plugin/Transform/endpunc.pm
↑ Summary
lib/Serge/Sync/Plugin/TranslationService/zing.pm »
| 1 | package Serge::Sync::Plugin::TranslationService::pootle; | ||||||||||
| 2 | 1 | ▶ | use parent Serge::Sync::Plugin::Base::TranslationService, Serge::Interface::SysCmdRunner; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Serge::Util qw(subst_macros); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | sub name { | ||||||||||
| 9 | 0 | ▶ | return 'Pootle translation server (http://pootle.translatehouse.org/) synchronization plugin'; | ||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | sub init { | ||||||||||
| 13 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | |||||||||||
| 15 | 0 | $self->SUPER::init(@_); | |||||||||
| 16 | |||||||||||
| 17 | 0 | $self->{optimizations} = 1; # set to undef to disable optimizations | |||||||||
| 18 | |||||||||||
| 19 | 0 | $self->merge_schema({ | |||||||||
| 20 | project_id => 'STRING', | ||||||||||
| 21 | manage_py_path => 'STRING', | ||||||||||
| 22 | }); | ||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | sub validate_data { | ||||||||||
| 26 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
validate_data: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 27 | |||||||||||
| 28 | 0 | $self->SUPER::validate_data; | |||||||||
| 29 | |||||||||||
| 30 | 0 | $self->{data}->{project_id} = subst_macros($self->{data}->{project_id}); | |||||||||
| 31 | 0 | $self->{data}->{manage_py_path} = subst_macros($self->{data}->{manage_py_path}); | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | die "'project_id' not defined" unless defined $self->{data}->{project_id}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | ▶ | die "'manage_py_path' not defined" unless defined $self->{data}->{manage_py_path}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | ▶ | die "'manage_py_path', which is set to '$self->{data}->{manage_py_path}', does not point to a valid file.\n" unless -f $self->{data}->{manage_py_path}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub run_manage_py { | ||||||||||
| 39 | 0 | ▶ | my ($self, $action, $langs, $capture) = @_; | ||||||||
|
Subroutine
run_manage_py: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 40 | |||||||||||
| 41 | 0 | my $command = $action.' --project='.$self->{data}->{project_id}; | |||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | if ($langs) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | 0 | foreach my $lang (sort @$langs) { | |||||||||
| 45 | 0 | $lang =~ s/-(\w+)$/'_'.uc($1)/e; # convert e.g. 'pt-br' to 'pt_BR' | |||||||||
| 46 | 0 | $command .= " --language=$lang"; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 0 | $command = $self->{data}->{manage_py_path}.' '.$command; | |||||||||
| 51 | 0 | print "Running '$command'...\n"; | |||||||||
| 52 | 0 | return $self->run_cmd($command, $capture); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | sub pull_ts { | ||||||||||
| 56 | 0 | ▶ | my ($self, $langs) = @_; | ||||||||
|
Subroutine
pull_ts: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | my $force = $self->{optimizations} ? '' : ' --overwrite'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | |||||||||||
| 60 | 0 | return $self->run_manage_py('sync_stores --skip-missing'.$force, $langs); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | sub push_ts { | ||||||||||
| 64 | 0 | ▶ | my ($self, $langs) = @_; | ||||||||
|
Subroutine
push_ts: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | my $force = $self->{optimizations} ? '' : ' --force'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | $self->run_manage_py('update_stores'.$force, $langs); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 1 | 1; | |||||||||