# Locale::Po4a::KernelHelp -- Convert kernel configuration help from/to PO files # # This program is free software; you may redistribute it and/or modify it # under the terms of GPL v2.0 or later (see COPYING). # # See gettext documentation for more info about PO files. ############################################################################ # Modules and declarations ############################################################################ use Pod::Parser; use Locale::Po4a::TransTractor qw(process new); use Locale::Po4a::Common; package Locale::Po4a::KernelHelp; use 5.16.0; use strict; use warnings; require Exporter; use vars qw(@ISA @EXPORT $AUTOLOAD); @ISA = qw(Locale::Po4a::TransTractor); @EXPORT = qw(); # new process write read writepo readpo); my $debug = 0; sub initialize { } sub parse { my $self = shift; my ( $line, $ref ); my $paragraph = ""; # Buffer where we put the paragraph while building my ($status) = 0; # Syntax of KH is: # descriptionvariablehelp text # Status will be: # 0 1 2 3 0 my ( $desc, $variable ); LINE: ( $line, $ref ) = $self->shiftline(); while ( defined($line) ) { chomp($line); print STDERR "status=$status;Seen >>$line<<:" if $debug; if ( $line =~ /^\#/ ) { print STDERR "comment.\n" if $debug; $self->pushline("$line\n"); } elsif ( $status == 0 ) { if ( $line =~ /\S/ ) { print STDERR "short desc.\n" if $debug; $desc = $line; $status++; } else { print STDERR "empty line.\n" if $debug; $self->pushline("$line\n"); } } elsif ( $status == 1 ) { print STDERR "var name.\n" if $debug; $variable = $line; $status++; $self->pushline( $self->translate( $desc, $ref, "desc_$variable" ) . "\n$variable\n" ); } elsif ( $status == 2 ) { $line =~ s/^ //; if ( $line =~ /\S/ ) { print STDERR "paragraph line.\n" if $debug; $paragraph .= $line . "\n"; } else { print STDERR "end of paragraph.\n" if $debug; $status++; $paragraph = $self->translate( $paragraph, $ref, "helptxt_$variable" ); $paragraph =~ s/^/ /gm; $self->pushline("$paragraph\n"); $paragraph = ""; } } elsif ( $status == 3 ) { if ( $line =~ s/^ // ) { if ( $line =~ /\S/ ) { print "begin of paragraph.\n" if $debug; $paragraph = $line . "\n"; $status--; } else { print "end of config option.\n" if $debug; $status = 0; $self->pushline("\n"); } } else { $self->unshiftline( $line, $ref ); $status = 0; } } else { die wrap_ref_mod( $ref, "po4a::kernelhelp", gettext("Syntax error") ); } # Reinit the loop ( $line, $ref ) = $self->shiftline(); } } sub docheader { return <, L, L, L, L =head1 AUTHORS Denis Barbier Martin Quinson (mquinson#debian.org) =head1 COPYRIGHT AND LICENSE Copyright © 2002 SPI, Inc. This program is free software; you may redistribute it and/or modify it under the terms of GPL v2.0 or later (see the COPYING file). =cut