Chameleon

Chameleon Svn Source Tree

Root/branches/Bungo/package/bin/po4a/lib/Locale/Po4a/KernelHelp.pm

1# Locale::Po4a::KernelHelp -- Convert kernel configuration help from/to PO files
2#
3# This program is free software; you may redistribute it and/or modify it
4# under the terms of GPL (see COPYING).
5#
6# This module converts POD to PO file, so that it becomes possible to
7# translate POD formatted documentation. See gettext documentation for
8# more info about PO files.
9
10############################################################################
11# Modules and declarations
12############################################################################
13
14use Pod::Parser;
15use Locale::Po4a::TransTractor qw(process new);
16use Locale::Po4a::Common;
17
18package Locale::Po4a::KernelHelp;
19
20use 5.006;
21use strict;
22use warnings;
23
24require Exporter;
25
26use vars qw(@ISA @EXPORT $AUTOLOAD);
27@ISA = qw(Locale::Po4a::TransTractor);
28@EXPORT = qw(); # new process write read writepo readpo);
29
30my $debug=0;
31
32sub initialize {}
33
34sub parse {
35 my $self=shift;
36 my ($line,$ref);
37 my $paragraph=""; # Buffer where we put the paragraph while building
38 my ($status)=0; # Syntax of KH is:
39 # description<nl>variable<nl>help text<nl><nl>
40 # Status will be:
41 # 0 1 2 3 0
42
43 my ($desc,$variable);
44
45 LINE:
46 ($line,$ref)=$self->shiftline();
47
48 while (defined($line)) {
49chomp($line);
50print STDERR "status=$status;Seen >>$line<<:" if $debug;
51
52if ($line =~ /^\#/) {
53 print STDERR "comment.\n" if $debug;
54 $self->pushline("$line\n");
55} elsif ($status == 0) {
56 if ($line =~ /\S/) {
57print STDERR "short desc.\n" if $debug;
58$desc=$line;
59$status ++;
60 } else {
61print STDERR "empty line.\n" if $debug;
62$self->pushline("$line\n");
63 }
64} elsif ($status == 1) {
65 print STDERR "var name.\n" if $debug;
66 $variable=$line;
67 $status++;
68
69 $self->pushline($self->translate($desc,$ref,"desc_$variable").
70 "\n$variable\n");
71
72} elsif ($status == 2) {
73 $line =~ s/^ //;
74 if ($line =~ /\S/) {
75print STDERR "paragraph line.\n" if $debug;
76$paragraph .= $line."\n";
77 } else {
78print STDERR "end of paragraph.\n" if $debug;
79$status++;
80$paragraph=$self->translate($paragraph,
81 $ref,
82 "helptxt_$variable");
83$paragraph =~ s/^/ /gm;
84$self->pushline("$paragraph\n");
85$paragraph ="";
86 }
87} elsif ($status == 3) {
88 if ($line =~ s/^ //) {
89if ($line =~ /\S/) {
90 print "begin of paragraph.\n" if $debug;
91 $paragraph = $line."\n";
92 $status--;
93} else {
94 print "end of config option.\n" if $debug;
95 $status=0;
96 $self->pushline("\n");
97}
98 } else {
99$self->unshiftline($line,$ref);
100$status=0;
101 }
102} else {
103 die wrap_ref_mod($ref, "po4a::kernelhelp", gettext("Syntax error"));
104}
105
106# Reinit the loop
107($line,$ref)=$self->shiftline();
108 }
109}
110
111sub docheader {
112 return <<EOT;
113#
114# *****************************************************
115# * GENERATED FILE, DO NOT EDIT *
116# * THIS IS NO SOURCE FILE, BUT RESULT OF COMPILATION *
117# *****************************************************
118#
119# This file was generated by po4a(7). Do not store it (in VCS, for example),
120# but store the PO file used as source file by pod-translate.
121#
122# In fact, consider this as a binary, and the PO file as a regular .c file:
123# If the PO get lost, keeping this translation up-to-date will be harder.
124#
125EOT
126}
1271;
128
129##############################################################################
130# Module return value and documentation
131##############################################################################
132
1331;
134__END__
135
136=encoding UTF-8
137
138=head1 NAME
139
140Locale::Po4a::KernelHelp - convert kernel configuration help from/to PO files
141
142=head1 DESCRIPTION
143
144Locale::Po4a::KernelHelp is a module to help the translation of
145documentation for the Linux kernel configuration options into other [human]
146languages.
147
148=head1 STATUS OF THIS MODULE
149
150This module is just written, and needs more tests. Most of the needed work
151will concern the tools used to parse this file (and configure the kernel),
152so that they accept to read the documentation from another (translated)
153file.
154
155=head1 SEE ALSO
156
157L<Pod::Parser>,
158L<Locale::Po4a::Man(3pm)>,
159L<Locale::Po4a::Pod(3pm)>,
160L<Locale::Po4a::TransTractor(3pm)>,
161L<po4a(7)|po4a.7>
162
163=head1 AUTHORS
164
165 Denis Barbier <barbier@linuxfr.org>
166 Martin Quinson (mquinson#debian.org)
167
168=head1 COPYRIGHT AND LICENSE
169
170Copyright 2002 by SPI, inc.
171
172This program is free software; you may redistribute it and/or modify it
173under the terms of GPL (see the COPYING file).
174
175=cut
176

Archive Download this file

Revision: 2840