LOCALE::PO4A::TRANSTRACTOR.3PM(1) User Contributed Perl Documentation :: PO4A :: - . PO4A ( PO) ( , ) . , , PO , PO4A . , : - ; - PO . , : - PO , ; - , , PO . : Input document --\ /---> Output document \ / (translated) +-> parse() function -----+ / \ Input PO --------/ \---> Output PO (extracted) () : , . B < > . <> . () , () , , . () , , . , B < , . "

" . , , '

' , . 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; } } , . ( PO4A . . : a. PO_IN_NAME PO b. File_in_name c. d. e. file_out_name () f. PO po_out_name () () ( ) : file_in_name (@) . file_in_charset ($) ( , UTF-8 ). file_out_name ($) . file_out_charset ($) ( , -8 ). po_in_name (@) PO . po_out_name ($) PO . (@) , . addendum_charset ($) . (%) PO4A . ( ): ($) . () . ($) (: 76). . PO- : b , b <->, b , b >, b <->, b >. ($$$) c << {{$ 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). . () . ($) . 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 . () . MSGFMT - . , PO , MSGFMT . :: Po4a :: po :: stats_get PO . : [normal use of the po4a document...] ($percent,$hit,$queries) = $document->stats(); print "We found translations for $percent\% ($hit from $queries) of strings.\n"; ($) l , , . , , ;) . , . / / . * 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. , . : , , , , . ()) , ( ) C << {{$ self-> {TT} {doc_in}} >> 2 . , c << $ : $ linenum >> . unshiftline ($$) << {$ -> {TT} {doc_in}} >> . ($) C << {$ self-> {TT} {doc_out}} >> . () << {$ -> {TT} {doc_out}} >> . . ($$$) : - - ( InputFile ) - ( ; :: po4a :: po :: getTextisation (); l , b ?>) . . : $self->translate("string","ref","type", 'wrap' => 1); <> . , , . B (: 76). . <> . : - , Po_out . - (PO_IN ), DOC_OUT . - Po_out , . () . ()) . get_in_charset () get_out_charset () ( ). . , PO , PO "" , , . , .desktop . , : - PO_IN_NAME ( ) - - _ , : $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)