diff options
author | Denis Barbier <barbier> | 2001-09-04 00:27:39 +0000 |
---|---|---|
committer | Denis Barbier <barbier> | 2001-09-04 00:27:39 +0000 |
commit | 02a1da72b4c48ca8732e67cf1a4c978adbe74f75 (patch) | |
tree | d495adff54d1089a18298e2ec43d4f5a955f12e8 /Perl/Webwml | |
parent | 4036f0d029693a60f3925b3f289f5bbf8ff4fa43 (diff) |
Read translation related informations found on wml::debian::translation-check
lines
CVS version numbers
Perl/Webwml/TransCheck.pm: INITIAL -> 1.1
Diffstat (limited to 'Perl/Webwml')
-rw-r--r-- | Perl/Webwml/TransCheck.pm | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/Perl/Webwml/TransCheck.pm b/Perl/Webwml/TransCheck.pm new file mode 100644 index 00000000000..4cd58de9885 --- /dev/null +++ b/Perl/Webwml/TransCheck.pm @@ -0,0 +1,159 @@ +#!/usr/bin/perl -w + +## Copyright (C) 2001 Denis Barbier <barbier@debian.org> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. + +=head1 NAME + +Webwml::TransCheck - retrieve information embedded in translated documents + +=head1 SYNOPSIS + + use Webwml::TransCheck; + my $tc = Webwml::TransCheck->new("foo.wml"); + my $rev = $tc->revision(); + +=head1 DESCRIPTION + +This module search for C<#use wml::debian::translation-check> line in files +and retrieve related information. + +=head1 METHODS + +=over 4 + +=cut + +package Webwml::TransCheck; +use Carp; +use strict; + +=item new + +This is the constructor. It has an argument, which is the filename to parse. + + my $tc = Webwml::TransCheck->new("foo.wml"); + +=cut + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = { + KEYS => { + maintainer => 'MAINT', + translation => 'REV', + original => 'ORIG', + maxdelta => 'MAX', + mindelta => 'MIN', + }, + DATA => {}, + }; + bless ($self, $class); + croak "Missing argument in \`new' method" unless @_; + $self->_read(@_); + return $self; +} + +sub _read { + my $self = shift; + my $file = shift + or croak "Missing argument in Webwml::TransCheck->new"; + my ($line, $key, $value); + open(FILE, "< $file") or croak "Unable to read $file\n"; + while ($line = <FILE>) { + if ($line =~ m/^\#use\s+wml::debian::translation-check/) { + # There may be continuation lines + while ($line =~ s/\\\s*\n$//s) { + $line .= <FILE> || last; + } + while (($key, $value) = each %{$self->{KEYS}}) { + $line =~ m/$key="([^"]+)"/ and + $self->{DATA}->{$value} = $1; + } + last; + } + } + close(FILE); +} + +=item maintainer + +Return the maintainer name of the translated document. + + my $maint = $tc->maintainer(); + +=cut + +sub maintainer { + my $self = shift; + return defined($self->{DATA}->{MAINT}) ? $self->{DATA}->{MAINT} : undef; +} + +=item revision + +Return the revision number of the original document. + + my $rev = $tc->revision(); + +=cut + +sub revision { + my $self = shift; + return defined($self->{DATA}->{REV}) ? $self->{DATA}->{REV} : undef; +} + +=item original + +Return the original document language, if not English. + + my $orig = $tc->original(); + +=cut + +sub original { + my $self = shift; + return defined($self->{DATA}->{ORIG}) ? $self->{DATA}->{ORIG} : undef; +} + +=item maxdelta + + my $maxdelta = $tc->maxdelta(); + +=cut + +sub maxdelta { + my $self = shift; + return defined($self->{DATA}->{MAX}) ? $self->{DATA}->{MAX} : undef; +} + +=item mindelta + + my $mindelta = $tc->mindelta(); + +=cut + +sub mindelta { + my $self = shift; + return defined($self->{DATA}->{MIN}) ? $self->{DATA}->{MIN} : undef; +} + +=back + +=head1 AUTHOR + +Copyright (C) 2001 Denis Barbier <barbier@debian.org> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +=cut + +1; + |