[Po4a-commits] r2475 - in /trunk: NEWS changelog lib/Locale/Po4a/Text.pm
nekral-guest at users.alioth.debian.org
nekral-guest at users.alioth.debian.org
Sun Jul 24 11:51:35 UTC 2011
Author: nekral-guest
Date: Sun Jul 24 11:51:34 2011
New Revision: 2475
URL: http://svn.debian.org/wsvn/po4a/?sc=1&rev=2475
Log:
* NEWS, lib/Locale/Po4a/Text.pm: Add support for control files.
Modified:
trunk/NEWS
trunk/changelog
trunk/lib/Locale/Po4a/Text.pm
Modified: trunk/NEWS
URL: http://svn.debian.org/wsvn/po4a/trunk/NEWS?rev=2475&op=diff
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Jul 24 11:51:34 2011
@@ -2,10 +2,18 @@
=======================================================================
-* Major changes in release 0.41 (2010-??-??)
+* Major changes in release 0.42 (UNRELEASED)
+
+Text:
+ * Add support for control files.
+
+=======================================================================
+
+* Major changes in release 0.41 (2010-12-01)
po4a-updatepo:
* --previous flag was not passed to msgmerge
+
po4a:
* Do no more generate backups for PO files.
* Fix the --srcdir option, master file was not found.
Modified: trunk/changelog
URL: http://svn.debian.org/wsvn/po4a/trunk/changelog?rev=2475&op=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Jul 24 11:51:34 2011
@@ -1,3 +1,7 @@
+2011-07-24 Nicolas François <nicolas.francois at centraliens.net>
+
+ * NEWS, lib/Locale/Po4a/Text.pm: Add support for control files.
+
2010-11-22 Denis Barbier <barbier-guest at alioth.debian.org>
* po4a: Fix parsing to allow empty commands in
Modified: trunk/lib/Locale/Po4a/Text.pm
URL: http://svn.debian.org/wsvn/po4a/trunk/lib/Locale/Po4a/Text.pm?rev=2475&op=diff
==============================================================================
--- trunk/lib/Locale/Po4a/Text.pm (original)
+++ trunk/lib/Locale/Po4a/Text.pm Sun Jul 24 11:51:34 2011
@@ -141,6 +141,15 @@
my $asciidoc = 0;
+=item B<control>[=I<tag list>]
+
+Handle control files.
+A comma separated list of tags to be translated can be provided.
+
+=cut
+
+my %control = ();
+
=back
=cut
@@ -149,6 +158,7 @@
my $self = shift;
my %options = @_;
+ $self->{options}{'control'} = "";
$self->{options}{'asciidoc'} = 1;
$self->{options}{'breaks'} = 1;
$self->{options}{'debianchangelog'} = 1;
@@ -190,7 +200,19 @@
$markdown=1;
}
- $asciidoc=1 if (defined $options{'asciidoc'});
+ if (defined $options{'asciidoc'}) {
+ $asciidoc=1;
+ }
+
+ if (defined $options{'control'}) {
+ if ($options{'control'} eq "1") {
+ $control{''}=1;
+ } else {
+ foreach my $tag (split(',',$options{'control'})) {
+ $control{$tag}=1;
+ }
+ }
+ }
}
sub parse {
@@ -240,6 +262,57 @@
$paragraph="";
$wrapped_mode = 1;
$self->pushline("$line\n");
+ } elsif ( $line =~ m/^([^ :]*): *(.*)$/
+ and %control) {
+ warn "Unrecognized section: '$paragraph'\n"
+ unless $paragraph eq "";
+ my $tag = $1;
+ my $val = $2;
+ my $t;
+ if ($control{''} or $control{$tag}) {
+ $t = $self->translate($val,
+ $self->{ref},
+ $tag.(defined $self->{controlkey}?", ".$self->{controlkey}:""),
+ "wrap" => 0);
+ } else {
+ $t = $val;
+ }
+ if (not defined $self->{controlkey}) {
+ $self->{controlkey} = "$tag: $val";
+ }
+ $self->pushline("$tag: $t\n");
+ $paragraph="";
+ $wrapped_mode = 1;
+ $self->{bullet} = "";
+ $self->{indent} = " ";
+ } elsif (%control and
+ $line eq " .") {
+ do_paragraph($self,$paragraph,$wrapped_mode,
+ "Long Description".(defined $self->{controlkey}?", ".$self->{controlkey}:""));
+ $paragraph="";
+ $self->pushline($line."\n");
+ $self->{bullet} = "";
+ $self->{indent} = " ";
+ } elsif (%control and
+ $line =~ m/^ Link: +(.*)$/) {
+ do_paragraph($self,$paragraph,$wrapped_mode,
+ "Long Description".(defined $self->{controlkey}?", ".$self->{controlkey}:""));
+ my $link=$1;
+ my $t1 = $self->translate("Link: ",
+ $self->{ref},
+ "Link",
+ "wrap" => 0);
+ my $t2 = $self->translate($link,
+ $self->{ref},
+ "Link".(defined $self->{controlkey}?", ".$self->{controlkey}:""),
+ "wrap" => 0);
+ $self->pushline(" $t1$t2\n");
+ $paragraph="";
+ } elsif (%control and
+ defined $self->{indent} and
+ $line =~ m/^$self->{indent}\S/) {
+ $paragraph .= $line."\n";
+ $self->{type} = "Long Description".(defined $self->{controlkey}?", ".$self->{controlkey}:"");
} elsif ( (defined $self->{verbatim})
and ($self->{verbatim} == 2)) {
# Untranslated blocks
@@ -258,6 +331,7 @@
$paragraph="";
$wrapped_mode = 1 unless defined($self->{verbatim});
$self->pushline($line."\n");
+ undef $self->{controlkey};
} elsif ($asciidoc and (not defined($self->{verbatim})) and
($line =~ m/^(\+|--)$/)) {
# List Item Continuation or List Block
More information about the Po4a-commits
mailing list