LOCALE::PO4A::TRANSTRACTOR.3PM(1) User Contributed Perl Documentation >> Locale::Po4a::TransTractor - >>>>>>>> >> Po4a (PO For Anything) >>>>>>>>>>>>>>>>>>>> gettext >>>>>>(>>>>>>>>>>>>>)> >>>>>> po4a >>>>>>>>>>>>>>>>>>>>>>>>>>>> PO >>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>> - >>>>>>; - >>>>>>>>> PO >>> >>>>>>>>> - >>> PO >>>>>>>>>>>>>>>>>>>>; - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PO >>>>>>> >>>>>>>>>>>> Input document --\ /---> Output document \ / (translated) +-> parse() function -----+ / \ Input PO --------/ \---> Output PO (extracted) >>>>>>>>>> parse() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> INTERNAL FUNCTIONS >>>>>>>>>>>>>>>>>>>>>>>>> SYNOPSIS>>>>>>>>>> >>>>>>> process() >>>>>>>>>>>>> new() >>>>>>>>>>>>>>>>>>>>>>>>>>> docheader() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> po4a(7) >> Educating developers about translations >>> >> >>>>>>>> "
" >>>>>>>>>>>>>>>>>>>>>>>>>> "
" >>>>>>>>>>>>>>>>>>>>>>>>>>> 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--; ) { # Not the first time we see
. # Reput the current line in input, # and put the built paragraph to output $self->unshiftline($line,$lref); # Now that the document is formed, translate it: # - Remove the leading tag $paragraph =~ s/^
//s; # - push to output the leading tag (untranslated) and the # rest of the paragraph (translated) $self->pushline( "
"
. $self->translate($paragraph,$pararef)
);
next PARAGRAPH;
} else {
# Append to the paragraph
$paragraph .= $line;
$pararef = $lref unless(length($pararef));
}
# Reinit the loop
($line,$lref)=$self->shiftline();
}
# Did not get a defined line? End of input file.
return;
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
document >>
>>>>>>>>>>>>>>
>> >>
process(%)
>>>>>>>>>>>>>>> po4a
>>>>>>>>>>>>>>>>>>>>>>>>>
a. >> po_in_name >>>>>> PO >>
b. >>> file_in_name >>>>>>>>>>
c. >>>>
d. >>>>>>>>>>>>
e. >>>>>>>> file_out_name (>>>>)
f. >>>> PO >>>> po_out_name (>>>>)
>>>>> new() >>>>>(>>>>>>)>
file_in_name (@)
>>>>>>>>>>>>>>>>>>>
file_in_charset ($)
Charset used in the input document (if it isn't specified, use
UTF-8).
file_out_name ($)
>>>>>>>>>>>>>>>>>
file_out_charset ($)
Charset used in the output document (if it isn't specified, use
UTF-8).
po_in_name (@)
>>>>>>>>>> PO
>>>>>>>>>>>>>>>>>>>>>>>
po_out_name ($)
>>>>>>>>>>> PO
>>>>>>>>>>>>>>>>>>>>>
addendum (@)
>>>>>>>>>>>>>>>>
addendum_charset ($)
>>>>>>>
new(%)
>>>> po4a >>>>>>>>
(>>>>>>>>>>>)>
verbose ($)
>>>>>>>
debug ($)
>>>>>
wrapcol ($)
The column at which we should wrap text in output document
(default: 76).
The negative value means not to wrap lines at all.
Also it accepts next options for underlying Po-files: porefs,
copyright-holder, msgid-bugs-address, package-name,
package-version, wrap-po.
>>>>>>
read($$$)
Add another input document data at the end of the existing array
"@{$self->{TT}{doc_in}}".
This function takes two mandatory arguments and an optional one.
* The filename to read on disk;
* The name to use as filename when building the reference in the
PO file;
* The charset to use to read that file (UTF-8 by default)
This array "@{$self->{TT}{doc_in}}" holds this input document data
as an array of strings with alternating meanings.
* The string $textline holding each line of the input text data.
* The string "$filename:$linenum" holding its location and called
as
"reference" ("linenum" starts with 1).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
parse() >>>
write($)
>>>>>>>>>>>>>>>
This translated document data are provided by:
* "$self->docheader()" holding the header text for the plugin, and
* "@{$self->{TT}{doc_out}}" holding each line of the main
translated text in the array.
>> PO >>
readpo($)
>>>>>>>>>>>>>>>>>>>>>>>>
PO>>>>>>>>>
writepo($)
>>>> PO >>>>>>>>>>
stats()
>>>>>>>>>>>>>>>>>>>>>>>>>>
msgfmt --statistic
>>>>>>>>>>>>>>>>>> PO
>>>>>>>>>>>>>>> msgfmt
>>>>>>>>>>>>>>>>> PO >>>
Locale::Po4a::Po::stats_get >>>>>>>>>>>
[normal use of the po4a document...]
($percent,$hit,$queries) = $document->stats();
print "We found translations for $percent\% ($hit from $queries) of strings.\n";
>>>>
addendum($)
>>>
po4a(7)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Perl
> shift/unshift > push/pop >>>>>
* Perl shift returns the first array item and drop it from the array.
* Perl unshift prepends an item to the array as the first array item.
* Perl pop returns the last array item and drop it from the array.
* Perl push appends an item to the array as the last array item.
>>>>>>>>>>>>>>>>>>>>>>>>>
input >>>>>>>>>>>>shift >>>>>>>
output >>>>>>>>>>>>>>>> push >>>
shiftline()
>>>>>> "@{$self->{TT}{doc_in}}"
>>>>>>>>>>>>>>>>
(>>>>>)>>>>>>>>>>>>>>>>>>>
"$filename:$linenum" >>>
unshiftline($$)
>>>>>>>>>>>>>>>>>>>>>>
"{$self->{TT}{doc_in}}" >>>>
pushline($)
>>>>> "{$self->{TT}{doc_out}}" >>>>
popline()
> "{$self->{TT}{doc_out}}" >>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>>>>>>>>
translate($$$)
>>>>>
- >>>>>>
- >>>>>> (>>>>>>>>>)
- >>>>>>(>>>>>>>>>>>>>>
Locale::Po4a::Po::gettextization() >>>>>>>>
po4a(7)>Gettextization: how does it work? >>)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$self->translate("string","ref","type",
'wrap' => 1);
wrap
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
wrapcol
the column at which we should wrap (default: the value of
wrapcol specified during creation of the TransTractor or 76).
The negative value will be substracted from the default.
comment
>>>>>>>>>>>>
>>>
- >>>>>>>>>>>> po_out>
- >>>>>>>(> po_in
>>>)>>>>>>>>>> doc_out>
- >>>>>>> po_out
>>>>>>>>>>>>>>>>>>>>>
>>>>
verbose()
>>>>>>>>>>>>>>>>> verbose
>>>
debug()
>>>>>>>>>>>>>>>>>>>>>>
get_in_charset()
This function return the charset that was provided as master
charset
get_out_charset()
>>>>>>>>>>>>>>>>>>>>(>>>>>>>>>>>>>>>>>>>>>>)>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PO >>>>>>>>> PO >>>>>
"CHARSET">>>>>>>>>>>>>>>>>>>>>>
>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
debconf >>> .desktop >>>
>>>>>>>>>>>>>>
- >>>>> po_in_name (>>>>>>>)
- >>>>>>>>>>>>>>>
- >>>>>>>>>>>>> pushline_all
>>>>>>>>>>>>>>>>>> pushline>
$self->pushline_all({ "Description[".$langcode."]=".
$self->translate($line,$ref,$langcode)
});
>>>>>> ;)
>>
Denis Barbier