LOCALE::PO4A::TRANSTRACTOR.3PM(1) User Contributed Perl Documentation Locale::Po4a::TransTractor - ( ). po4a (PO for anything - PO ) ( , ) gettext , . po4a , , PO . , : - ; - PO . , : - PO , ; - , , PO . : Input document --\ /---> Output document \ / (translated) +-> parse() function -----+ / \ Input PO --------/ \---> Output PO (extracted) parse() : , . . , . process() , new(), , . docheader() , . , 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--; ) { # 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; } } , , . process(%) po4a . . : . PO po_in_name . file_in_name . . . file_out_name ( ) . 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}}". 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 . Locale::Po4a::Po::stats_get function PO . : [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) , . , ;) , . , . shift/unshift push/pop Perl. * 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. , . : , shift, , push. shiftline() ( ) "@{$self->{TT}{doc_in}}" 2 . "$filename:$linenum". unshiftline($$) Unshift- shift- "{$self->{TT}{doc_in}}". pushline($) push "{$self->{TT}{doc_out}}". popline() pop push- "{$self->{TT}{doc_out}}". . translate($$$) : - - (. ) - (. ; Locale::Po4a::Po::gettextization(); po4a(7), ?) . . : $self->translate("string","ref","type", 'wrap' => 1); wrap . , , . wrapcol (: wrapcol TransTractor 76). . comment . : - push , po_out. - ( po_in) doc_out. - po_out . verbose() TransTractor . debug() TransTractor . get_in_charset() get_out_charset() ( ). . , PO, PO ,,CHARSET", , .. TransTractor , debconf , .desktop . , : - po_in_name ( ) - translate - pushline_all, pushline , map: $self->pushline_all({ "Description[".$langcode."]=". $self->translate($line,$ref,$langcode) }); ;) Denis Barbier Martin Quinson (mquinson#debian.org) Jordi Vilalta perl v5.42.0 2025-11-22 LOCALE::PO4A::TRANSTRACTOR.3PM(1)