diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 11:26:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-17 11:26:17 +0000 |
commit | 5df6c2aefebe3d2abcc939a88e294876d59f03ca (patch) | |
tree | 63fb332a0f21ddb91cb789c80cf64e134d373463 /lib/Locale/Po4a/KernelHelp.pm | |
parent | Initial commit. (diff) | |
download | po4a-5df6c2aefebe3d2abcc939a88e294876d59f03ca.tar.xz po4a-5df6c2aefebe3d2abcc939a88e294876d59f03ca.zip |
Adding upstream version 0.72.upstream/0.72
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/Locale/Po4a/KernelHelp.pm')
-rw-r--r-- | lib/Locale/Po4a/KernelHelp.pm | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/lib/Locale/Po4a/KernelHelp.pm b/lib/Locale/Po4a/KernelHelp.pm new file mode 100644 index 0000000..96cd21f --- /dev/null +++ b/lib/Locale/Po4a/KernelHelp.pm @@ -0,0 +1,170 @@ +# 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: + # description<nl>variable<nl>help text<nl><nl> + # 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 <<EOT; +# +# ***************************************************** +# * GENERATED FILE, DO NOT EDIT * +# * THIS IS NO SOURCE FILE, BUT RESULT OF COMPILATION * +# ***************************************************** +# +# This file was generated by po4a(7). Do not store it (in VCS, for example), +# but store the PO file used as source file by pod-translate. +# +# In fact, consider this as a binary, and the PO file as a regular .c file: +# If the PO get lost, keeping this translation up-to-date will be harder. +# +EOT +} +1; + +############################################################################## +# Module return value and documentation +############################################################################## + +1; +__END__ + +=encoding UTF-8 + +=head1 NAME + +Locale::Po4a::KernelHelp - convert kernel configuration help from/to PO files + +=head1 DESCRIPTION + +Locale::Po4a::KernelHelp is a module to help the translation of +documentation for the Linux kernel configuration options into other [human] +languages. + +=head1 STATUS OF THIS MODULE + +This module is just written, and needs more tests. Most of the needed work +will concern the tools used to parse this file (and configure the kernel), +so that they accept to read the documentation from another (translated) +file. + +=head1 SEE ALSO + +L<Pod::Parser>, +L<Locale::Po4a::Man(3pm)>, +L<Locale::Po4a::Pod(3pm)>, +L<Locale::Po4a::TransTractor(3pm)>, +L<po4a(7)|po4a.7> + +=head1 AUTHORS + + Denis Barbier <barbier@linuxfr.org> + 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 |