LOCALE::PO4A::TRANSTRACTOR.3PM(1) User Contributed Perl Documentation >>>>>>>> Locale::Po4a::TransTractor - >>>>>>>>>> >>>>>>>>>> >>>>>>>>> (>> Trans[lator ex]Tractor). >>>>>>>> >>>>> >>>>>>> po4a (PO for anything, PO >>>>> > >>> >>>>>) >>>>>>>> >>>>>>>>>> >>>>>>>> >>>>>>>> (> >>> >>>>> >>>>> -- >>>>>>>>> >>>>>>>>), >>>>>>>>> >>>>>>>>>>> gettext > >>> >>>>>>>, >>>>> >> >>>>>>>>>> >>>>> >>>>>>>>> >>>>>>>>>>>, >>>>>>>> >>> >>>>>>>>>>>>. >>>>>> >>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> po4a, >>>>>>>>>>>>> >>> >>>>>>> >>>>>>>>>, >>>>>> >>>>>>>>>>> >>>>>, >>>>>>>>>> >> > PO->>>> > >>>>>> >> >>>>>>>>> > >>>>>>>> >>>>>>>>>. >>>>> >>>>>>>>>, >> >>>>>>>>> >> >>>> >>>>>>>>> >>>>>>>>>: - >>>>>>>> >>> >>>>>>>>; - PO->>>>, >>>>>>>>>> >>>>>>>. >> >>>>>> >> >>>>>>>>>>: - >>>>>> PO->>>>, >>> >>>>>>>>> >>>>>>>>>> >>>>>>>>>>> >>>>> >> >>>>>>>> >>>>>>>>>; - >>>>>>>>>>>> >>>>>>>> > >>> >> >>>>>>>>>>, >>> > >>>>>>>, >> >>> >>>>>>>>>>> >>>>>> >>>>>>>> >>>>>>>>>>, >>>>>>>>>> >> >>>>>>> PO->>>>>. >>>> >>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>>> >>>>> >>>>>>>>: >>>>>>> >>>>>>>> --\ /---> >>>>>>>> >>>>>>>> \ / (>>>>>>>>>>>>) +-> >>>>>>> parse() ------+ / \ >>>>>>> PO --------/ \---> >>>>>>>> PO (>>>>>>>>>>>) >>>>>>>, >>>>>>> >>>>>> >>>> >>>>>>>>>>>>>> > >>>>> >>>>>>> parse() >>>>>> >>>>> >>>>>>>>>> >>> >>>>>>: >>>>>> >>>>>>>> >>>>>>>>>, >>>>>>>>> >>>>>>>>> >>>>>>>>> > >>>>>>>>>> >>>>>>>>>>> >>>>>. >>> >>>>>>>> >>>>>> >>>>>>>, >>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>, >>>>>>>>> >>>> > >>>>>>> >>>>>>>>>> >>>>>>>. >>. >>>>> >>>>>> > >>>>>>> >>>>>>> >>>>>>>>. >>> >>>>>>> >>>>>>>>>> >> >>>>>>> process() >>>>>>>>> >>>>, >> >>>> >> >>>>>> >>>>>>>>>>>> >>>>>>> new() > >>>>>>> >>>>>>>> >>>>>>>>>> > >>> >>>>>>>>, >>> >>>>>>>> >>>>>>>> >>> >>>>>>> >>>>>>>>>>>>>>. docheader() >>> >>>>>>> >>>>>>>>>> >>>>>>>>>, >>>>>>> >> >>>>>> >>>>>>>> > >>>>>>>>>> >>>>>>>>>. >>>>>>>>> >>>>>>>>>>>>>>>, >> >>>>> >>>>>>>>>>>> >> >>>>>>> >>>>>. >>> >>>> >>> >>>>>, >>. >>>>>> Educating developers about translations > po4a(7). >>>>>>> >>>>>>>>>> > >>>>>>>>> >>>>>>> >>>>>>>>>>>>> >>>>>> >>>>>>>, >>>>>>>>>>>> > "
". >>> >>>>>>>> >> >>>>>>>>>>>>, >>> >>>>>>>> >>>>>> >>>>>>>>>>>>>>, >.> > >>> >>>>>>>>>>>> >>>>>> >>>> '
', > >>>>>> >>>>> >>> >>>>>>>>> > >>>>>> >>>>>>. sub parse { my $self = shift; PARAGRAPH: while (1) { my ($paragraph,$pararef)=("",""); my $first=1; my ($line,$lref)=$self->shiftline(); while (defined($line)) { if ($line =~ m/
/ && !$first--; ) { # >>> >> >>>>>> >>>, >>>>> >> >>>>>
. # >>>>>> >>>>>>> >>>>>> >>>>>>> > >>>>> >>>>>, # > >>>>>>>>>>> >>>>> >>>>>>>> >> >>>>> $self->unshiftline($line,$lref); # Now that the document is formed, translate it: # - >>>>>> >>>>>>> >>> $paragraph =~ s/^
//s; # - >>>>>>>> >> >>>>> >>>> >>> (>>>>>>>>>>>>>>) # > >>> >>>>> (>>>>>>>>>>>>) $self->pushline( "
"
. $self->translate($paragraph,$pararef)
);
next PARAGRAPH;
} else {
# >>>>>>>>>>>> > >>>>> >>>>>>>> >>>>>>
$paragraph .= $line;
$pararef = $lref unless(length($pararef));
}
# >>>>>>>>>>>>>>>>>>>> >>>>
($line,$lref)=$self->shiftline();
}
# >> >>>>>>>> >>>>>>? >>>>>> >>> >>>>> >>>>>.
return;
}
}
>>>>> >>>>>>>>>> >>>>>>>
>>>>>>>>>>>>>>> >>>>>>>,
>> >>>>>> >>>>>>>>>>>>>
>>> >>>>> > >>>>>>>
>>>>>>>>>> >>>>>>>>>>,
>>>>>>>>>>>>>>> >
>>>>>>>>> >>>>>>>.
>>>>>>>>> >>>>>>>>> >>>
>>>>>>>>, >>>>>>>>>>>>
>>> >>>>>>
Constructor
process(%)
>>> >>>>>>> >>>>>
>>>>>>>>> >>>, >>> >>>
>>>>>, > >>>>>>>>>> po4a >>
>>>> >>>>>. >> >>>>>>>>>
>>>>>> >>>> >>>>>>>>> >
>>>> >>>>. >>>>>>>>:
a. >>>>>> >>> PO->>>>>,
>>>>>>>>> > po_in_name
b. >>>>>> >>> >>>>>>>>
>>>>>>>>>, >>>>>>>>> >
file_in_name
c. >>>>>>>>> >>>>>>
>>>>>>>>>
d. >>>>>> > >>>>>>>>> >>>
>>>>>>>>> >>>>>>>>>>
e. >>>>>>>>>>
>>>>>>>>>>>> >>>>>>>>
> file_out_name (>>>> >>>>>>>)
f. >>>>>>>>>> >>>>>>>>>>>
PO->>>> > po_out_name (>>>>
>>>>>>>)
>>>>>>>>>, >>>>> >>>,
>>>>>>> >>>>>>>>>>> new() (>
>>>>>>>>> >>>>>):
file_in_name (@)
>>>>>> >>>> >>>>>>
>>>>>>> >>>>>>>>>>.
file_in_charset ($)
>>>>>>>>>,
>>>>>>>>>>>> >>
>>>>>>> >>>>>>>>> (>>>>
>> >>>>>>>,
>>>>>>>>>>>> UTF-8).
file_out_name ($)
>>> >>>>> >>>>>>>>>
>>>>>>>>>.
file_out_charset ($)
>>>>>>>>>,
>>>>>>>>>>>> >
>>>>>>>> >>>>>>>>>
(>>>> >> >>>>>>>,
>>>>>>>>>>>> UTF-8).
po_in_name (@)
>>>>>> >>>> >>>>>>>
PO->>>>>>, >>>>>>> >>>>>
>>>>>>>>>>>>>> >>>
>>>>>>>> >>>>>>>>>.
po_out_name ($)
>>> >>>>>>>>> PO->>>>>,
>>>>>>>>>>> >>>>>>,
>>>>>>>>>>> >>
>>>>>>>> >>>>>>>>>.
addendum (@)
>>>>>> >>>> >>>>>>
>>>>>>>>>>.
addendum_charset ($)
>>>>>>>>> >>>>>>>>>.
new(%)
>>>>>>> >>>>>
po4a->>>>>>>>. >>>>>>>>>>
>>>>>>>>> (> >>>>,
>>>>>>>>>>>> > >>>>>>>>
>>>>>>>>>):
verbose ($)
>>>>>>>>>>>>> >>>>>>>
>>>>>>>>>>>.
debug ($)
>>>>>>>>>>>>> >>>>>
>>>>>>>.
wrapcol ($)
>>>>>>>>>> >>>>>>>> >
>>>>>>, >>>>> >>>>>>>
>>>>> > >>>>>>>>
>>>>>>>>> >>>>>>>>>>>
>> >>>>> >>>>>>
(>>>>>>>> >> >>>>>>>>>:
76).
>>>>>>>>>>>>>
>>>>>>>> >>>>>>>>, >>>
>>>>>> >>>>>> >>
>>>>>>>>>>>.
>>>>> >>> >>>>>>>
PO->>>>>> >>>>>>>>>>>
>>>>>>>>> >>>>>>>>>: porefs,
copyright-holder, msgid-bugs-address, package-name,
package-version, wrap-po.
>>>>>>>>>>>>>>> >>>>>>>
>>>>>>>>>>
read($$$)
>>>>>>>> >>>>>>>>>>
>>>>>>> >>>>>>>>
>>>>>>>>> > >>>>>
>>>>>>>>>>>>> >>>>>>>
"@{$self->{TT}{doc_in}}".
>>> >>>>>>> >>>>>>>>>
>>> >>>>>>>>>>>>
>>>>>>>>> > >>>>
>>>>>>>>>>>>>>. * >>>
>>>>>, >>>>>>>>>>>> >
>>>>>; * >>> >>>>>>>>>>>>
> >>>>>>>> >>>>> >>>>>
>>> >>>>>>>> >>>>>> >
PO->>>>>; * >>>>>>>>>,
>>>>>>>>>>>> >>> >>>>>>
>>>>> (>> >>>>>>>>> UTF-8)
>>>>>> "@{$self->{TT}{doc_in}}"
>>>>>>>> >>>>>>
>>>>>>>> >>>>>>>>> >
>>>> >>>>>>> >>>>> >
>>>>>>>>>>>>>
>>>>>>>>>>.
* >>>>>> $textline >>>>>>>>
>>>>>> >>>>>> >>>>>>>
>>>>>>>>> >>>>>>.
* >>>>>> "$filename:$linenum" >>>>>>>>
>> >>>>>>>>>>>>>> >
>>>>>>>>>>
">>>>>>>" ("linenum"
>>>>>>>>>> > 1).
>>>>>>>> >>>>>>>>, >>>
>>> >>>>>>> >>>>>> >>
>>>>>>>>>>>. >>> >>>>>>>
>>>>>>>>>>>> >>>>>>> parse(),
>>>>> >> >>>>>>>>>
>>>>>>>>>>> >>>>>>>
>>>>> > >>>>>>>>.
write($)
>>>>>>>>>> >>>>>>>>>>>>
>>>>>>>> > >>>>>>>>> >>>
>>>>>.
>>> >>>>>>>>>>>> >>>>>>
>>>>>>>>>>>>>>> >
>>>>>>>:
* "$self->docheader()" >>>>>>>> >>>>>
>>>>>>>>> >>> >>>>>>>, >
* "@{$self->{TT}{doc_out}}" >>>>>>>> >
>>>>>>> >>>>>> >>>>>>
>>>>>>>> >>>>>>>>>>>>>
>>>>>>.
>>>>>>>>>>>>>>> PO->>>>>>>
readpo($)
>>>>>>>>> >>>>>>>>>>
>>>>> (>>> >>>>>>>>
>>>>>>>> > >>>>>>>>
>>>>>>>>>) >
>>>>>>>>>>>> >>>>>>>
PO->>>>. >>>>>> >>>>>>>>>>
>> >>>>>>>>>.
writepo($)
>>>>>>>>>> >>>>>>>>>>>
PO->>>> > >>>> > >>>>>>>>>
>>>>>>.
stats()
>>>>>>>>>> >>>>>>>>>
>>>>>>>>>> >
>>>>>>>>>>> >> >>>>>>
>>>>>> >>>>>>>>.
>>>>>>>> >>>>>>>>, >>>
>>> >> >> >>>>>>>>>>,
>>>>>>> >>>>>>>>>
>>>>>>>> msgfmt --statistic.>>>>>
>>>>>>>>> >>>>>>>>>> >
>>>>>>>> >>>>>>>>>>>>>
>>>>> PO, > >> >>>>> >>> msgfmt
>>>>>>>> > >>>>>>>>>
>>>>>. >>> >>>>>>> >>>
>>>>>>> Locale::Po4a::Po::stats_get,
>>>>>>>>>>> > >>>>>>>>
PO->>>>>. >>>>>>
>>>>>>>>>>>>>:
($percent,$hit,$queries) = $document->stats();
print "We found translations for $percent\% ($hit from $queries) of strings.\n";
>>>>>>>>>>>>>>>
>>>>>>>>>>>
addendum($)
>>>>>>>>>>, >>>>>>>>>> >
po4a(7) >>> >>>>>>>>> >>>>>
>>>>>>>>> >>>>>>>>>> >
>>>, >>> >>>>> >>>>>>>>>
> >>> >>>>>>>>>>>>
>>>>>>> >> >>>>>>. >>>>>
>>>>>>>>> >>>>>>>> >
>>>>>>>>>>>>>
>>>>>>>>>, >>>>>>
>>>>>>>>> >>> >>> > >>>
>>>>>>>, > >>> >>>>>> ;)
> >>>>>> >>>>>> >>>
>>>>>>> >>>>>>>>>>
>>>>>>>> >>>>>>>>,
>>>>>>>> >> >>>>.
>>>>>>>>>> >>>>>>>,
>>>>>>>>>>>> >>> >>>>>>>>
>>>>>>>>>>> >>>>>>>>
>>>>>>>>> >>>>>>> >>>>>>,
>>>>>>>>>>>>>> >>>>>>>>
>>>>>>
>>> >>>>>>>>> >>>>>>>
>>>>>> > >>>>>>>>
>>>>>>>> >>>>>>
>>>>>>>>>>>>> >>>>>>
>>>>>>>. >>> >>>>> >>>>>>
>> shift/unshift > push/pop > Perl.
* >>>>>>>> shift > Perl >>>>>>> >> >>>>>>> >>>>>> >>>>>>> > >>>>>>>>>> >>> >>>>>>>>.
* >>>>>>>> unshift > Perl >>>>>>>>> >>>>>>> > >>>>>> >>>>>>>.
* >>>>>>>> pop > Perl >>>>>>> >> >>>>>>> >>>>>>>>> >>>>>>> > >>>>>>>>>> >>> >>>>>>>>.
* >>>>>>>> push > Perl >>>>>>>>> >>>>>>> > >>>>> >>>>>>>.
>>>>>> >>>> >>>>>>>>> >
>>>>>, > >>>>>> -- > >>>>>>.
>>>>>>>>>: >>> >>>>> >>>
>>>>>>>>>> >>>>>> >>>>>> --
>>, >>> >>>> shift, > >>> >>>>>>
>> >>>>>> >>>>>>>> >>>
>>>>>>>>> > >>>>>, >>> >>>
>>>>>> push.
shiftline()
>>> >>>>>>> >>>>>>>>>>
>>>>>> >>>>>> >>>
>>>>>>> >
>>>>>>>>>>>>>>> >>>>>>
(>>>>>>>>>>> > >>>>
>>>>>>>) >> >>>>>>>
"@{$self->{TT}{doc_in}}" > >>>>>>> >>>
>>>>>> 2 >>>>>>>>
>>>>>>>. >>>>> >>>>>>
>>>>>>>>>>>> >>>>>>>
"$filename:$linenum".
unshiftline($$)
>>>>>>>> >>>>>>>>>
>>>>>>>> shiftline(). >>>>>> >
>>>>>>>>>>>>>> >>>>>>
>>>>>>>>>> >>>>>>> >
>>>>>> >>>>>>> "{$self->{TT}{doc_in}}".
pushline($)
>>>>>>>> >>>>> >>>>>> >
>>>>> >>>>>>> "{$self->{TT}{doc_out}}".
popline()
>>>>>>> >> >>>>>>>
"{$self->{TT}{doc_out}}" >>>>>>>>>
>>>>>>> > >>>>>>>>>> >>>
>>>>>>>>.
>>>>>>> >>>>> >>>
>>>>>>>>>>>
>>>>>>>>>>>>> >>>>
>>>>>>> >>> >>>>>>>>>
>>>>>>, >>>>>>> >>>>>>
>>>> >>>>>>>>>.
translate($$$)
>>>>>>>>>>>> >>>>>>>>>:
- >>>>>> >>> >>>>>>>>
- >>>>>> >> >>> >>>>>> (>.>.
>> >>>>>>> >> >>>>>>>
>>>>>)
- >>> >>>>>> (>.>.
>>>>>>>>> >>>>>>>> >>
>>>>>>>>>>> >>>>;
>>>>>>>>>>>> >
Locale::Po4a::Po::gettextization(); >>. >>>>>
po4a(7), >>>>>> >>> >>>
>>>>>>>>?)
>>> >>>>>>> >>>>> >>>>>
>>>>>>>>> >>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>. >>> >>>>>>
>>>> >>>>>>>>>>>> > >>>>
>>>>. >>>>>>>>:
$self->translate("string","ref","type",
'wrap' => 1);
wrap
>>>>>>>>>> >>>>>>>>,
>>>>>>>>>>>, >>>>> >>
>> >>>>>>>, >>> >>>>>>>
> >>>>>> >> >>>>>. >>>>
>>, >>>>>>>
>>>>>>>>>>>> >>>>>>
>>>>> >>>>>>> >>>>>>>>
>>> >>> >>>>>>>>>>> >
>>>>>>>>> >>>>>>>>
>>>>> > >>>>>>>>> >>
>>>>>>>>>>>>> (>>>>>>>
wrap()).
wrapcol
>>>>>>>>>> >>>>>>>> >
>>>>>>, >>>>> >>>>>>>
>>>>>> >>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>> >>>>>> >> >>>>>
>>>>>> (>> >>>>>>>>>:
>>>>>>>> wrapcol, >>>>>>>>>
>>> >>>>>>>> TransTractor >>> 76).
>>>>>>>>>>>>>
>>>>>>>> >>>>>
>>>>>>>>>> >> >>>>>>>>
>> >>>>>>>>>.
comment
>>>>>>>>>>>>>>
>>>>>>>>>>> >>>
>>>>>>>>>> > >>>>>>.
>>>>>>>>:
- >>>>>>>>>> >>>>>>,
>>>>>> > >>> > po_out.
- >>>>>>>>>> >>>>>>>
>>>>>> (>>>>>>>>> > po_in),
>>>>> >>>>>> >>>
>>>>>>> doc_out.
- >>>>>>>>>>>> >>>>>>>>>
>>> >>>>>>>>>>>>>>>
>>>>> >>>>> >>>>>>>>>
>> > po_out > >>>>> >>>>>>>>>
>>>>>>>>>.
>>>>>> >>>>>>>
verbose()
>>>>>>>>>> >>>>>>>> 1,
>>>> >>>>>>>> verbose >>>
>>>>>>> >> >>>>>
>>>>>>>> TransTractor.
debug()
>>>>>>>>>> >>>>>>>> 1,
>>>> >>>>>>>> debug >>>
>>>>>>> >> >>>>>
>>>>>>>> TransTractor.
get_in_charset()
>>> >>>>>>> >>>>>>>>>>
>>>>>>>>>, >>>>>>> >>>>
>>>>>>>>>>>>> >
>>>>>>>> >>>>>>>>
get_out_charset()
>>> >>>>>>> >>>>>>
>>>>>>>>>, >>>>>>>
>>>>>> >>>>>>>>>>>>>> >
>>>>>>>> >>>>>>>>>
(>>>>>> >>> >>>>>>> >>>
>>>>>> >>>>>>>>>>>>
>>>>>>>>> >>>>>>>>
>>>>>>>>> >>>, >>> >>>
>>>> >>>>>>>).
>>> >>>>>>> >>>>>
>>>>>>>>>>>> >>>>>>>>
>>>>>>>>>, >>>>>>>>> >
>>>>>>>>> >>>>>>. >>>>
>>>>>>>>> >> >>>>
>>>>>>>, >>>>>
>>>>>>>>>>>>>>
>>>>>>>>>, >>>>>>>>> >>
>>>>>>> PO->>>>>, >>>> >>
>> >>>>>>> PO->>>>>
>>>>>>>>> >>>>>
>>>>>>>> "CHARSET", >>>>>>>
>>>>>> >>>>>>>>>
>>>>>>>> >>>>>>>>>, >
>>>> >>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>> >> >>>>>.
>>>>> >> >>>>>>>
>>>>> >> >>>>>>>>>>>
>>>>>>>> TransTractor >>>>>>>> >>,
>>> >> >> >>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> >>>>>>>>>,
>>>>>>>>>> >>> >>>>>,
>>>>> >>> >>>>>>> debconf >>>
>>>>> .desktop.
>>> >>>>>>> >>>> >>>>>>>>
>>>>>>>>>> >>>>>>
>>>>>>>>> >>>>>>>>>
>>>>>>>>>>:
- >>>>> >>> > >>>> po_in_name
(>>>>>> >>> >>>>>>> >>>>>)
- >>>>>>>> >>>>>>>>
>>>>>>>> >>> >>>>>>>>
>>>>>>>> >>>>>
- >>>>>>> >>>>>>> pushline_all,
>>>>>>> >>>>>>>>>>> >>
pushline >> >>>>>> >>>>>>>>>>>
>>> >>>> >>>>>>,
>>>>>>>>> map->>>>>>>>
>>>>>>>>>:
$self->pushline_all({ "Description[".$langcode."]=".
$self->translate($line,$ref,$langcode)
});
>>>>>>>>>, >>>>>>>>>> >>
>>>>> ;)
>>>>>>
>>>>> >>>>>> (Denis Barbier)