"Fossies" - the Fresh Open Source Software Archive

Member "wine-docs-1.8/po4a/lib/Locale/Po4a/NewsDebian.pm" (25 Dec 2015, 4139 Bytes) of package /linux/misc/old/wine-docs-1.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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