Root/
Source at commit 2462 created 9 years 8 months ago. By ifabio, Split out states generator from acpi_patcher (Credits to Clover Teams) | |
---|---|
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 | ␊ |
14 | use Pod::Parser;␊ |
15 | use Locale::Po4a::TransTractor qw(process new);␊ |
16 | use Locale::Po4a::Common;␊ |
17 | ␊ |
18 | package Locale::Po4a::KernelHelp;␊ |
19 | ␊ |
20 | use 5.006;␊ |
21 | use strict;␊ |
22 | use warnings;␊ |
23 | ␊ |
24 | require Exporter;␊ |
25 | ␊ |
26 | use vars qw(@ISA @EXPORT $AUTOLOAD);␊ |
27 | @ISA = qw(Locale::Po4a::TransTractor);␊ |
28 | @EXPORT = qw(); # new process write read writepo readpo);␊ |
29 | ␊ |
30 | my $debug=0;␊ |
31 | ␊ |
32 | sub initialize {}␊ |
33 | ␊ |
34 | sub 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)) {␊ |
49 | ␉chomp($line);␊ |
50 | ␉print STDERR "status=$status;Seen >>$line<<:" if $debug;␊ |
51 | ␊ |
52 | ␉if ($line =~ /^\#/) {␊ |
53 | ␉ print STDERR "comment.\n" if $debug;␊ |
54 | ␉ $self->pushline("$line\n");␊ |
55 | ␉} elsif ($status == 0) {␊ |
56 | ␉ if ($line =~ /\S/) {␊ |
57 | ␉␉print STDERR "short desc.\n" if $debug;␊ |
58 | ␉␉$desc=$line;␊ |
59 | ␉␉$status ++;␊ |
60 | ␉ } else {␊ |
61 | ␉␉print 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/) {␊ |
75 | ␉␉print STDERR "paragraph line.\n" if $debug;␊ |
76 | ␉␉$paragraph .= $line."\n";␊ |
77 | ␉ } else {␊ |
78 | ␉␉print 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/^ //) {␊ |
89 | ␉␉if ($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 | ␊ |
111 | sub 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 | #␊ |
125 | EOT␊ |
126 | }␊ |
127 | 1;␊ |
128 | ␊ |
129 | ##############################################################################␊ |
130 | # Module return value and documentation␊ |
131 | ##############################################################################␊ |
132 | ␊ |
133 | 1;␊ |
134 | __END__␊ |
135 | ␊ |
136 | =encoding UTF-8␊ |
137 | ␊ |
138 | =head1 NAME␊ |
139 | ␊ |
140 | Locale::Po4a::KernelHelp - convert kernel configuration help from/to PO files␊ |
141 | ␊ |
142 | =head1 DESCRIPTION␊ |
143 | ␊ |
144 | Locale::Po4a::KernelHelp is a module to help the translation of␊ |
145 | documentation for the Linux kernel configuration options into other [human]␊ |
146 | languages.␊ |
147 | ␊ |
148 | =head1 STATUS OF THIS MODULE␊ |
149 | ␊ |
150 | This module is just written, and needs more tests. Most of the needed work␊ |
151 | will concern the tools used to parse this file (and configure the kernel),␊ |
152 | so that they accept to read the documentation from another (translated)␊ |
153 | file.␊ |
154 | ␊ |
155 | =head1 SEE ALSO␊ |
156 | ␊ |
157 | L<Pod::Parser>,␊ |
158 | L<Locale::Po4a::Man(3pm)>,␊ |
159 | L<Locale::Po4a::Pod(3pm)>,␊ |
160 | L<Locale::Po4a::TransTractor(3pm)>,␊ |
161 | L<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 | ␊ |
170 | Copyright 2002 by SPI, inc.␊ |
171 | ␊ |
172 | This program is free software; you may redistribute it and/or modify it␊ |
173 | under the terms of GPL (see the COPYING file).␊ |
174 | ␊ |
175 | =cut␊ |
176 |