Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/package/bin/po4a/lib/Locale/Po4a/NewsDebian.pm

1#!/usr/bin/perl -w
2
3# Po4a::NewsDebian.pm
4#
5# extract and translate translatable strings from a NEWS.Debian documents
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21########################################################################
22
23=encoding UTF-8
24
25=head1 NAME
26
27Locale::Po4a::NewsDebian - convert NEWS.Debian documents from/to PO files
28
29=head1 DESCRIPTION
30
31The po4a (PO for anything) project goal is to ease translations (and more
32interestingly, the maintenance of translations) using gettext tools on
33areas where they were not expected like documentation.
34
35Locale::Po4a::NewsDebian is a module to help the translation of the
36NEWS.Debian files into other [human] languages. Those files are where
37maintainer are supposed to write the important news about their package.
38
39=head1 OPTIONS ACCEPTED BY THIS MODULE
40
41NONE.
42
43=head1 STATUS OF THIS MODULE
44
45Not tested.
46
47A finer split of the entries may be preferable (search for /^ */, for
48example), but this version is more robust and NEWS.Debian entries are not
49supposed to change that often.
50
51=cut
52
53package Locale::Po4a::NewsDebian;
54
55use 5.006;
56use strict;
57use warnings;
58
59require Exporter;
60use vars qw(@ISA @EXPORT);
61@ISA = qw(Locale::Po4a::TransTractor);
62@EXPORT = qw();
63
64use Locale::Po4a::TransTractor;
65use Locale::Po4a::Common;
66
67
68sub initialize {}
69
70sub parse {
71 my $self = shift;
72
73 my ($blanklines)=(""); # We want to preserve the blank lines inside the entry, and strip the extrem ones
74
75 my ($body)=""; # the accumulated paragraph
76 my ($bodyref)="";
77 my ($bodytype)="";
78
79 my ($line,$lref);
80
81 # main loop
82 ($line,$lref)=$self->shiftline();
83 print "seen >>$line<<\n" if $self->debug();
84 while (defined($line)) {
85
86# Begining of an entry
87if ($line =~ m/^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)((\s+[-0-9a-z]+)+)\;/i) {
88
89 die wrap_ref_mod($lref, "po4a::newsdebian", dgettext("po4a", "Begin of a new entry before the end of previous one"))
90 if (length ($body));
91
92 $self->pushline($line."\n");
93
94 # Signature of this entry
95 $bodyref = $lref;
96 $bodytype = $line;
97
98 # eat all leading empty lines
99 ($line,$lref)=$self->shiftline();
100 while (defined($line) && $line =~ m/^\s*$/) {
101print "Eat >>$line<<\n" if $self->debug();
102($line,$lref)=$self->shiftline();
103 }
104 # ups, ate one line too much. Put it back.
105 $self->unshiftline($line,$lref);
106
107
108 # get ready to read the entry (cleanups)
109 $blanklines = "";
110
111# End of current entry
112} elsif ($line =~ m/^ \-\- (.*) <(.*)> .*$/) { #((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4}(\s+\([^\\\(\)]\))?) *$/) {
113
114 $self->translate($body, $bodyref, $bodytype,
115 wrap=>0);
116 $body="";
117
118# non-specific line
119} else {
120
121 if ($line =~ /^\s*$/) {
122$blanklines .= "$line";
123 } else {
124$body .= $blanklines.$line;
125$blanklines = "";
126 }
127}
128
129($line,$lref)=$self->shiftline();
130print "seen >>".($line || '')."<<\n" if $self->debug();
131 }
132}
133
1341;
135
136=head1 AUTHORS
137
138This module is loosely inspired from /usr/lib/dpkg/parsechangelog/debian, which is:
139
140 Copyright (C) 1996 Ian Jackson. This is free software; see the GNU
141 General Public Licence version 2 or later for copying conditions. There
142 is NO warranty.
143
144The adaptation for po4a was done by:
145
146 Martin Quinson (mquinson#debian.org)
147
148=head1 COPYRIGHT AND LICENSE
149
150 Copyright (c) 1996 by Ian Jackson.
151 Copyright 2005 by SPI, inc.
152
153This program is free software; you may redistribute it and/or modify it
154under the terms of GPL (see the COPYING file).
155

Archive Download this file

Revision: 1871