| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | # -*- coding: utf-8 -*- | ||||||||||||||||||||||||||||
| 3 | { | ||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use FindBin; BEGIN {do "$FindBin::RealBin/libdir.pl"} | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||
| 8 | #---------------------------------------- | ||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use YATT::Lite::Factory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use YATT::Lite::Entities qw(*YATT *CON *SYS); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use YATT::Lite::Util::CmdLine qw(parse_opts parse_params); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use YATT::Lite::Util::FindMethods; # For debugging aid. | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | # Try x FindMethods($this, qr/^entity_/) | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | #---------------------------------------- | ||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use parent qw/YATT::Lite::Object/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | use YATT::Lite::MFields | ||||||||||||||||||||||||||||
| 20 | 1 | ▶ | qw/site | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | write | ||||||||||||||||||||||||||||
| 22 | lang | ||||||||||||||||||||||||||||
| 23 | quiet | ||||||||||||||||||||||||||||
| 24 | dir | ||||||||||||||||||||||||||||
| 25 | merge | ||||||||||||||||||||||||||||
| 26 | 1 | /; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #---------------------------------------- | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | my MY $cmd = MY->new(MY->parse_opts(\@ARGV, undef | |||||||||||||||||||||||||||
| 31 | , {w => 'write' | ||||||||||||||||||||||||||||
| 32 | , q => 'quiet' | ||||||||||||||||||||||||||||
| 33 | , d => 'dir' | ||||||||||||||||||||||||||||
| 34 | , m => 'merge' | ||||||||||||||||||||||||||||
| 35 | })); | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | my $site = YATT::Lite::Factory->load_factory_offline(dir => $cmd->{dir}) | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | or die "Can't find YATT app script!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | $cmd->{site} = $site; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | foreach my $path (@ARGV ? @ARGV : $site->cget('doc_root')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 1 | ▶ | if (-d $path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 1 | my $yatt = $site->load_yatt($path); | |||||||||||||||||||||||||||
| 45 | 1 | $yatt->configure(debug_cgen => $ENV{DEBUG}); | |||||||||||||||||||||||||||
| 46 | 1 | my $saveas = $yatt->fn_msgfile($cmd->{lang}); | |||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ($cmd->{merge} || $cmd->{write}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$cmd->{"merge"} or $cmd->{"write"}
MC/DC0%0/2
$cmd->{"merge"} or $cmd->{"write"}
$cmd->{"merge"}
$cmd->{"write"}
Truth table33%1/3
A or B
A= $cmd->{"merge"}B= $cmd->{"write"}
| |||||||||||||||||||||||||||||
| 48 | 0 | $yatt->get_lang_msg($cmd->{lang}); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | # XXX: Work around for ns confliction bug. | ||||||||||||||||||||||||||||
| 51 | 1 | my @items = public_only($yatt, $yatt->list_items); | |||||||||||||||||||||||||||
| 52 | 1 | ▶ | unless ($cmd->{quiet}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | print STDERR join("\n ", "parsing:", @items), "\n"; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | my @msglist = $yatt->lang_extract_lcmsg($cmd->{lang}, \@items); | |||||||||||||||||||||||||||
| 57 | 1 | ▶ | unless (-r $saveas) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 1 | unshift @msglist, $cmd->default_header; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 1 | ▶ | if ($cmd->{write}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | Locale::PO->save_file_fromarray($saveas, \@msglist); | |||||||||||||||||||||||||||
| 62 | 0 | print "Saved: $saveas\n"; | |||||||||||||||||||||||||||
| 63 | } else { | ||||||||||||||||||||||||||||
| 64 | 1 | print $_->dump for @msglist; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } else { | ||||||||||||||||||||||||||||
| 67 | 0 | die "NIMPL"; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | sub after_new { | ||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 73 | 1 | (my MY $self) = @_; | |||||||||||||||||||||||||||
| 74 | 1 | ▶ | $self->{lang} ||= $self->default_lang; | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"lang"} ||= $self->default_lang
MC/DC0%0/2
$self->{"lang"} ||= $self->default_lang
$self->{"lang"}
$self->default_lang
Truth table33%1/3
A ||= B
A= $self->{"lang"}B= $self->default_lang
| |||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | ▶ | sub default_lang {'en'} | ||||||||||||||||||||||||||
|
Subroutine
default_lang: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | use POSIX qw/strftime/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub default_header { | ||||||||||||||||||||||||||
|
Subroutine
default_header: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | 1 | my ($pack) = @_; | |||||||||||||||||||||||||||
| 82 | 1 | my $po = Locale::PO->new(-msgid => '', -msgstr => | |||||||||||||||||||||||||||
| 83 | "Project-Id-Version: PACKAGE VERSION\n" | ||||||||||||||||||||||||||||
| 84 | ."Report-Msgid-Bugs-To: \n" | ||||||||||||||||||||||||||||
| 85 | ."POT-Creation-Date: ".strftime('%Y-%m-%d %H:%M%z', localtime time)."\n" | ||||||||||||||||||||||||||||
| 86 | ."PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||||||||||||||||||||||||||||
| 87 | ."Last-Translator: FULL NAME <EMAIL\@ADDRESS>\n" | ||||||||||||||||||||||||||||
| 88 | ."Language-Team: LANGUAGE <LL\@li.org>\n" | ||||||||||||||||||||||||||||
| 89 | ."Language: \n" | ||||||||||||||||||||||||||||
| 90 | ."MIME-Version: 1.0\n" | ||||||||||||||||||||||||||||
| 91 | ."Content-Type: text/plain; charset=UTF-8\n" | ||||||||||||||||||||||||||||
| 92 | ."Content-Transfer-Encoding: 8bit\n"); | ||||||||||||||||||||||||||||
| 93 | 1 | $po->fuzzy(1); | |||||||||||||||||||||||||||
| 94 | 1 | $po; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | # 2011-12-07 18:16+0900 | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub public_only { | ||||||||||||||||||||||||||
|
Subroutine
public_only: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 100 | 1 | my ($yatt) = shift; | |||||||||||||||||||||||||||
| 101 | grep { | ||||||||||||||||||||||||||||
| 102 | 1 | $yatt->find_part($_)->cget('public') | |||||||||||||||||||||||||||
| 103 | } @_; | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||