[Po4a-devel][CVS] po4a/lib/Locale/Po4a Sgml.pm,1.23,1.24
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv12397/lib/Locale/Po4a
Modified Files:
Sgml.pm
Log Message:
Implement a quiet mode
Index: Sgml.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Sgml.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Sgml.pm 14 Jul 2004 19:08:03 -0000 1.23
+++ Sgml.pm 16 Jul 2004 04:11:58 -0000 1.24
@@ -235,13 +235,15 @@
# don't translate entries composed of one entity
if ( (($string =~ /^&[^;]*;$/) || ($options{'wrap'} && $string =~ /^\s*&[^;]*;\s*$/))
&& !($self->{options}{'include-all'}) ){
- warn sprintf(gettext("po4a::sgml: msgid skipped to help translators (contains only an entity)"), $string)."\n";
+ warn sprintf(gettext("po4a::sgml: msgid skipped to help translators (contains only an entity)"), $string)."\n"
+ unless $self->verbose() <= 0;
return $string;
}
# don't translate entries composed of tags only
if ( $string =~ /^(((<[^>]*>)|\s)*)$/
&& !($self->{options}{'include-all'}) ) {
- warn sprintf(gettext("po4a::sgml: msgid skipped to help translators (contains only tags)"), $string)."\n";
+ warn sprintf(gettext("po4a::sgml: msgid skipped to help translators (contains only tags)"), $string)."\n"
+ unless $self->verbose() <= 0;
return $string;
}
@@ -295,7 +297,8 @@
warn sprintf(gettext(
"po4a::sgml: Trying to handle a XML document as a SGML one.\n".
"po4a::sgml: Feel lucky if it works, help us implementing a proper XML\n".
- "po4a::sgml: backend if it does not."),$filename)."\n";
+ "po4a::sgml: backend if it does not."),$filename)."\n"
+ unless $self->verbose() <= 0;
$xmlprolog=$1;
}
# Get the prolog
20 years, 4 months
[Po4a-devel][CVS] po4a/lib/Locale/Po4a TransTractor.pm,1.20,1.21
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv12321/lib/Locale/Po4a
Modified Files:
TransTractor.pm
Log Message:
Export some more function; verbose<0 means quiet
Index: TransTractor.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/TransTractor.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- TransTractor.pm 16 Jul 2004 00:49:34 -0000 1.20
+++ TransTractor.pm 16 Jul 2004 04:11:18 -0000 1.21
@@ -10,10 +10,11 @@
use subs qw(makespace);
use vars qw($VERSION @ISA @EXPORT);
-$VERSION="0.16.4";
+$VERSION="0.17";
@ISA = ();
@EXPORT = qw(process translate
- read write readpo writepo);
+ read write readpo writepo
+ getpoout setpoout);
use Carp qw(croak);
use Locale::Po4a::Po;
@@ -414,6 +415,9 @@
sub getpoout {
return $_[0]->{TT}{po_out};
}
+sub setpoout {
+ $_[0]->{TT}{po_out} = $_[1];
+}
sub readpo {
$_[0]->{TT}{po_in}->read($_[1]);
}
@@ -550,7 +554,7 @@
}
if ($mode eq "before") {
- if ($self->verbose()) {
+ if ($self->verbose() > 0) {
map { print STDERR sprintf(dgettext("po4a","Adding the addendum %s before the line:\n%s"),
$filename,$_)."\n" if (/$position/);
} @{$self->{TT}{doc_out}};
@@ -564,7 +568,7 @@
if ($line =~ m/$position/) {
print STDERR sprintf(dgettext("po4a",
"Adding the addendum %s after the section begining with the line:\n%s"),
- $filename,mychomp($line))."\n" if ($self->verbose());
+ $filename,mychomp($line))."\n" if ($self->verbose() > 0);
while ($line=shift @{$self->{TT}{doc_out}}) {
last if ($line=~/$boundary/);
push @newres,$line;
@@ -575,7 +579,7 @@
"Next section begins with:\n".
"%s\n".
"Addendum added before this line."),
- mychomp($line))."\n" if ($self->verbose());
+ mychomp($line))."\n" if ($self->verbose() > 0);
push @newres,$content;
push @newres,$line;
} else {
@@ -583,13 +587,13 @@
"This section ends with:\n".
"%s\n".
"Addendum added after this line."),
- mychomp($line))."\n" if ($self->verbose());
+ mychomp($line))."\n" if ($self->verbose() > 0);
push @newres,$line;
push @newres,$content;
}
} else {
printf STDERR (dgettext("po4a","Can't find the end of the section in the file. Addendum added at the end of the file."))."\n"
- if ($self->verbose());
+ if ($self->verbose() > 0);
push @newres,$content;
}
}
@@ -754,7 +758,7 @@
if (defined $_[1]) {
$_[0]->{TT}{verbose} = $_[1];
} else {
- return $_[0]->{TT}{verbose};
+ return $_[0]->{TT}{verbose} || 0; # undef and 0 have the same meaning, but one generates warnings
}
}
20 years, 4 months
[Po4a-devel][CVS] po4a/lib/Locale/Po4a Chooser.pm,1.11,1.12
by Martin Quinson
Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv12192/lib/Locale/Po4a
Modified Files:
Chooser.pm
Log Message:
Improve robustness (against bug in po4a* scripts)
Index: Chooser.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Chooser.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Chooser.pm 25 May 2004 17:48:03 -0000 1.11
+++ Chooser.pm 16 Jul 2004 04:10:29 -0000 1.12
@@ -26,6 +26,9 @@
my ($module)=shift;
my (%options)=@_;
+ die gettext("Need to provide a module name to the Chooser")."\n"
+ unless defined $module;
+
my $modname;
if ($module eq 'kernelhelp') {
$modname = 'KernelHelp';
20 years, 4 months
[Po4a-devel][CVS] po4a Makefile,1.2,1.3
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv12044
Modified Files:
Makefile
Log Message:
Add the po4a script; rename the tar target to dist
Index: Makefile
===================================================================
RCS file: /cvsroot/po4a/po4a/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile 16 Jul 2004 00:46:45 -0000 1.2
+++ Makefile 16 Jul 2004 04:09:40 -0000 1.3
@@ -1,7 +1,7 @@
#!/usr/bin/make -f
# This file is public domain software, originally written by Joey Hess.
-bins = gettextize updatepo translate normalize
+bins = po4a po4a-gettextize po4a-updatepo po4a-translate po4a-normalize
libs = $(basename $(notdir $(wildcard lib/Locale/Po4a/*.pm)))
docs = $(subst .7.pod,,$(notdir $(wildcard doc/*.pod)))
langs = $(basename $(notdir $(wildcard po/pod/*.po)))
@@ -37,13 +37,13 @@
# so input file is temporarily copied.
for bin in $(bins) ; do \
for lang in $(langs) ; do \
- if [ -e po/pod/po4a-$$bin.$$lang.pod ] ; then \
+ if [ -e po/pod/$$bin.$$lang.pod ] ; then \
mkdir -p mantmp/$$lang/man1; \
- cp po/pod/po4a-$$bin.$$lang.pod mantmp/po4a-$$bin.pod && \
+ cp po/pod/$$bin.$$lang.pod mantmp/$$bin.pod && \
pod2man --section=1 --center='Po4a Tools' --release='Po4a Tools' \
- mantmp/po4a-$$bin.pod > mantmp/$$lang/man1/po4a-$$bin.1; \
- gzip -9 mantmp/$$lang/man1/po4a-$$bin.1; \
- rm -f mantmp/po4a-$$bin.pod; \
+ mantmp/$$bin.pod > mantmp/$$lang/man1/$$bin.1; \
+ gzip -9 mantmp/$$lang/man1/$$bin.1; \
+ rm -f mantmp/$$bin.pod; \
fi; \
done; \
done
@@ -102,7 +102,7 @@
done \
done
-tar: Build
+dist: Build
./Build dist
.PHONY: build clean install build-install po-install man-install tar
20 years, 4 months
[Po4a-devel][CVS] po4a/po/bin Makefile,1.13,1.14
by Martin Quinson
Update of /cvsroot/po4a/po4a/po/bin
In directory haydn:/tmp/cvs-serv11855/po/bin
Modified Files:
Makefile
Log Message:
add the new 'po4a' script
Index: Makefile
===================================================================
RCS file: /cvsroot/po4a/po4a/po/bin/Makefile,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Makefile 29 Jun 2004 19:35:06 -0000 1.13
+++ Makefile 16 Jul 2004 04:08:32 -0000 1.14
@@ -1,7 +1,7 @@
# List here all source files with translatable strings.
MODULE=po4a
PODFILES=$(wildcard ../../lib/Locale/Po4a/*.pm) \
- ../../po4a-gettextize ../../po4a-normalize ../../po4a-translate ../../po4a-updatepo
+ ../../po4a ../../po4a-gettextize ../../po4a-normalize ../../po4a-translate ../../po4a-updatepo
LANGS=$(basename $(wildcard *.po))
20 years, 4 months
[Po4a-devel][CVS] po4a MANIFEST,1.10,1.11 Build.PL,1.1,1.2
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv11855
Modified Files:
MANIFEST Build.PL
Log Message:
add the new 'po4a' script
Index: MANIFEST
===================================================================
RCS file: /cvsroot/po4a/po4a/MANIFEST,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- MANIFEST 29 Jun 2004 19:41:20 -0000 1.10
+++ MANIFEST 16 Jul 2004 04:08:32 -0000 1.11
@@ -37,6 +37,7 @@
# po/pod/po4a-updatepo.fr.pod
# the binaries
+po4a
po4a-gettextize
po4a-normalize
po4a-translate
Index: Build.PL
===================================================================
RCS file: /cvsroot/po4a/po4a/Build.PL,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Build.PL 29 Jun 2004 19:39:35 -0000 1.1
+++ Build.PL 16 Jul 2004 04:08:32 -0000 1.2
@@ -7,7 +7,7 @@
requires => {Locale::gettext => '1.01',
SGMLS => 0},
script_files => ['po4a-gettextize', 'po4a-updatepo',
- 'po4a-translate', 'po4a-normalize'],
+ 'po4a-translate', 'po4a-normalize', 'po4a'],
add_to_cleanup => ['t/tmp'],
dist_abstract => 'Tools for helping translation of documentation',
dist_author => ['Martin Quinson <martin.quinson(a)tuxfamily.org>',
20 years, 4 months
[Po4a-devel][CVS] po4a/po/pod Makefile,1.13,1.14
by Martin Quinson
Update of /cvsroot/po4a/po4a/po/pod
In directory haydn:/tmp/cvs-serv11855/po/pod
Modified Files:
Makefile
Log Message:
add the new 'po4a' script
Index: Makefile
===================================================================
RCS file: /cvsroot/po4a/po4a/po/pod/Makefile,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Makefile 16 Jul 2004 00:45:41 -0000 1.13
+++ Makefile 16 Jul 2004 04:08:32 -0000 1.14
@@ -1,5 +1,5 @@
# List here all source files with translatable strings.
-SCRIPTS=po4a-gettextize po4a-updatepo po4a-translate po4a-normalize
+SCRIPTS=po4a po4a-gettextize po4a-updatepo po4a-translate po4a-normalize
LIBS=Po.pm TransTractor.pm Pod.pm Man.pm Sgml.pm Chooser.pm KernelHelp.pm Dia.pm
DOCS=po4a.7
20 years, 4 months
[Po4a-devel][CVS] po4a po4a,NONE,1.1
by Martin Quinson
Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv11730
Added Files:
po4a
Log Message:
The script we spoke about. At least, its first incarnation ;)
--- NEW FILE: po4a ---
#! /usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# po4a -- Update both the po files and translated documents in one shoot
# $Id: po4a,v 1.1 2004/07/16 04:08:03 mquinson-guest Exp $
#
# Copyright 2002, 2003, 2004 by Martin Quinson <Martin.Quinson(a)ens-lyon.fr>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of GPL (see COPYING).
my $VERSION=$Locale::Po4a::TransTractor::VERSION;
=head1 NAME
po4a - Update both the po files and translated documents in one shoot
=head1 SYNOPSIS
po4a [-dhvV] E<lt>config_fileE<gt>
=head1 DESCRIPTION
The po4a (po for anything) project goal is to ease translations (and more
interstingly, the maintenance of translation) using gettext tools on areas
where they were not expected like documentation.
The C<po4a> program is in charge of updating both the po files (to sync
them to the original documents) and the translated documents (to sync
them to the po files). The main point is to make the use of po4a easier
without having to remember of the command line options.
It also allows you to mix document having different formats into the same
pot files so that you can have only one such file per project.
This behaviour can be mimicked by the other tools of the po4a suite (for
example with makefiles), but it is rather difficult to do, and exausting to
redo the same complicated makefiles for each project using po4a.
=head1 CONFIGURATION FILE SYNTAX
The (mandatory) argument is the path to the configuration file to use.
Its syntax aims at being simple and close to the configuration files used
by the intl-tools projects.
Comments in this files are noted by the char '#'. It comments everthing
until the end of the line. Lines can be continued by escaping the end of line.
All non blank lines must begin with a [] command, followed by its arguments.
(sound difficult said that way, but it is rather easy, I hope ;)
=head2 Specifying the paths to translator inputs
First, you have to specify where the translator input files (ie, the files
used by translators to do their job) are located. It can be done by such a line:
[po4a_paths] doc/l10n/project.doc.pot fr:doc/l10n/fr.po de:doc/l10n/de.po
The command is thus 'po4a_paths'. The first argument is the path to the pot
file to use. All subsequent arguments are of the self-explanationary form:
<lang>:<path to the po file for this lang>
=head2 Specifying the documents to translates
You now naturally have to to specify which documents are translated, their
format, and where to put the translations. It can be made by such lines:
[type: sgml] doc/my_stuff.sgml fr:doc/fr/mon_truc.sgml de:doc/de/mein_cram.sgml
[type: pod] script fr:doc/fr/script.1 de:doc/de/script.1 \
add_fr:doc/l10n/script.fr.add
This should be rather self-explanationary also. Note that in the second case,
doc/l10n/script.fr.add is an addendum to add to the french version of this document.
Please refer to po4a(7) for more information about the addendums.
More formally, the format is:
[type: <format>] <master_doc> <lang>:<localized_doc>* add_<lang>:<addendum>*
=head1 OPTIONS
=over 4
=item -h, --help
Show a short help message.
=item -V, --version
Displays the version of the script and exits.
=item -v, --verbose
Increase the verbosity of the program.
=item -q, --quiet
Decrease the verbosity of the program.
=item -d, --debug
Outputs some debugging informations.
=back
=head1 SHORTCOMMING
=over 4
=item
Does not allow to pass any options to the modules.
=item
Does not allow to specify the threshold under which the translations are discarded.
=item
Dupplicates some code with the po4a-* programs.
=back
Patch welcome ;)
=head1 SEE ALSO
L<po4a(7)>, L<po4a-gettextize(1)>, L<po4a-updatepo(1)>, L<po4a-translate(1)>, L<po4a-normalize(1)>.
=head1 AUTHORS
Denis Barbier <barbier(a)linuxfr.org>
Martin Quinson <martin.quinson(a)tuxfamily.org>
=head1 COPYRIGHT AND LICENSE
Copyright 2002, 2003, 2004 by SPI, inc.
This program is free software; you may redistribute it and/or modify it
under the terms of GPL (see COPYING file).
=cut
use 5.006;
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
use Locale::Po4a::Chooser;
use Locale::Po4a::TransTractor;
use Pod::Usage qw(pod2usage);
use Locale::gettext;
use POSIX; # Needed for setlocale()
setlocale(LC_MESSAGES, "");
textdomain('po4a');
sub show_version {
print sprintf(gettext(
"%s version %s.\n".
"written by Martin Quinson and Denis Barbier.\n\n".
"Copyright (C) 2002, 2003, 2004 Software of Public Interest, Inc.\n".
"This is free software; see source code for copying\n".
"conditions. There is NO warranty; not even for\n".
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
), "po4a", $VERSION)."\n";
exit 0;
}
my ($help,$type,$debug,$verbose,$quiet,@options);
$verbose = 0;
$debug = 0;
Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
GetOptions(
'help|h' => \$help,
'verbose|v' => \$verbose,
'debug|d' => \$debug,
'quiet|q' => \$quiet,
'version|V' => \&show_version
) or pod2usage(1);
# Argument check
$help && pod2usage (0);
$verbose = 1 if $debug;
$verbose = -1 if $quiet;
my %options = (
"verbose" => $verbose,
"debug" => $debug);
foreach (@options) {
if (m/^([^=]*)=(.*)$/) {
$options{$1}="$2";
} else {
$options{$_}=1;
}
}
my $config_file= shift(@ARGV) || pod2usage(1);
# Check file existence
-e $config_file || die sprintf(gettext("File %s does not exist."),$config_file)."\n";
# Parse the config file
my ($pot_filename) = "";
my (%po_filename); # po_files: '$lang'=>'$path'
my (%document); # '$master'=> {'format'=>'$format'; '$lang'=>'$path'; 'add_$lang'=>('$path','$path') }
open CONFIG,"$config_file" || die sprintf(gettext("Can't open %s: %s"),$config_file,$!)."\n";
my ($line,$nb) = ("",0);
while (<CONFIG>) {
$nb++;
s/#.*//;
$line.=$_;
next if ($line =~ s/\\$//);
next unless ($line =~ /\S/);
$line =~ s/ +/ /g;
$line =~ s/^ //;
$line =~ s/ $//;
die sprintf("%s:%d: ".gettext("Syntax error.")."\n",$config_file,$nb)
unless ($line =~ m/^\[([^\]]*)\] (\S+) (.*)?$/);
my ($cmd,$main,$args)=($1,$2,$3);
print "cmd=[$cmd]; main=$main; args=\"$args\"\n" if $debug;
die sprintf("%s:%d: ".
gettext("The first argument (%s) must not contain any colon (':')")."\n",
$config_file,$nb,$main)
if ($main =~ /:/);
if ($cmd eq "po4a_paths") {
die sprintf("%s:%d: ".
gettext("'po4a_path' redeclared").
"\n",
$config_file,$nb)
if (length $pot_filename);
$pot_filename = $main;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
gettext("Unparsable argument '%s'").
"\n",
$config_file,$nb,$arg)
unless ($arg =~ /^([^:]*):(.*)/);
$po_filename{$1}=$2;
}
} elsif ($cmd =~ m/type: *(.*)/) {
$document{$main}{'format'} = $1;
foreach my $arg (split(/ /,$args)) {
die sprintf("%s:%d: ".
gettext("Unparsable argument '%s'").
"\n",
$config_file,$nb,$arg)
unless ($arg =~ /^([^:]*):(.*)/);
push @{$document{$main}{$1}},$2;
}
} else {
die sprintf("%s:%d: ".
gettext("Unparsable command '%s'")."\n",
$config_file,$nb,$cmd);
}
$line = "";
}
close CONFIG; # don't care about error here
die gettext("po4a_paths not declared. Dunno where to find the pot and po files")."\n"
unless (length $pot_filename);
# make a big pot
if (-e $pot_filename) {
print sprintf(gettext("Updating %s:")."\n",$pot_filename)
if $verbose;
} else {
print sprintf(gettext("Creating %s:")."\n",$pot_filename)
if $verbose;
}
my $potfile=Locale::Po4a::Po->new();
foreach my $master (keys %document) {
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'},%options);
$doc->setpoout($potfile);
my @file_in_name;
push @file_in_name, $master;
$doc->process('file_in_name' => \@file_in_name);
$potfile = $doc->getpoout();
}
$potfile->write($pot_filename);
# update all po files
my $lang;
foreach $lang (sort keys %po_filename) {
if (-e $po_filename{$lang}) {
print STDERR sprintf(gettext("Updating %s:")."\n",$po_filename{$lang})
if $verbose;
system ("msgmerge","-U",$po_filename{$lang},$pot_filename) == 0 ||
die sprintf(gettext("Error while running msgmerge: %s"),$!)."\n";
system "msgfmt --statistics -v -o /dev/null ".$po_filename{$lang}
if $verbose;
} else {
print STDERR sprintf(gettext("Creating %s:")."\n",$po_filename{$lang})
if $verbose;
system ("cp",$pot_filename,$po_filename{$lang}) == 0 ||
die sprintf(gettext("Error while copying the po file: %s"),$!)."\n";
}
}
# update all translations
foreach my $master (keys %document) {
LANG: foreach $lang (keys %{$document{$master}}) {
next if $lang eq "format" || $lang =~ /^add_/;
my $doc=Locale::Po4a::Chooser::new($document{$master}{'format'} ,%options);
my (@file_in_name,@file_out_name,@po_in_name);
push @file_in_name, $master;
push @file_out_name, $document{$master}{$lang};
push @po_in_name, $po_filename{$lang};
$doc->process('file_in_name' => \@file_in_name,
'file_out_name' => \@file_out_name,
'po_in_name' => \@po_in_name);
my ($percent,$hit,$queries) = $doc->stats();
if ($percent<80) {
print STDERR sprintf(gettext("Translation of %s discarded: only %s%% are translated."),
$master,$percent)."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
next LANG;
}
foreach my $add ($document{$master}{add_$lang}) {
if ( !$doc->addendum($_) ) {
die sprintf(gettext("Addendum %s does apply to %s (translation discarded)."),
$add,$master)."\n";
unlink($document{$master}{$lang}) if (-e $document{$master}{$lang});
next LANG;
}
}
$doc->write($document{$master}{$lang});
}
}
__END__
20 years, 4 months
[Po4a-devel][CVS] po4a/t 20-xml.t,1.2,1.3
by Martin Quinson
Update of /cvsroot/po4a/po4a/t
In directory haydn:/tmp/cvs-serv12599/t
Modified Files:
20-xml.t
Log Message:
Shut off the XML warning
Index: 20-xml.t
===================================================================
RCS file: /cvsroot/po4a/po4a/t/20-xml.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- 20-xml.t 16 Jul 2004 00:45:41 -0000 1.2
+++ 20-xml.t 16 Jul 2004 03:15:07 -0000 1.3
@@ -16,7 +16,7 @@
"-I '^\"POT-Creation-Date: ' -I '^\"Content-Type:' -I '^\"Content-Transfer-Encoding:'";
my $diff_pod_flags= " -I 'This file was generated by po4a' ";
-$tests[0]{'run'} = "perl ../po4a-gettextize -f sgml -m data-20/text.xml -p tmp/xml.po >/dev/null";
+$tests[0]{'run'} = "perl ../po4a-gettextize -f sgml -m data-20/text.xml -p tmp/xml.po 2>/dev/null";
$tests[0]{'test'} = "diff -u tmp/xml.po data-20/xml.po $diff_po_flags";
$tests[0]{'doc'} = "gettextize well simple xml documents";
20 years, 4 months
[Po4a-devel][RFCs] configuration file format (+ addendum change?)
by martin.quinson@free.fr
Hello,
now that po4a is rather stable and reliable (thanks to the test suite), my
feeling is that the main showstopper preventing po4a from being widly used is
the way to use it. It's far too complicated, with 2 tools to use at each
update, each of them requiring 3 or more options. My goal (beside becoming
imortal/worldmaster/whatever) would be to solve that situation.
I would like to come up with a design of configuration file which would allow
people to do the two most often used actions (po4a-updatepo & po4a-translate)
in one shoot as simple as "po4a -c configuration_file".
The chalenge here is to not report the complexity into the config file, but
come up with a simple design.
I'm thinking about that since a long time, and I'm still unsure about how to
achieve it. For each master file (ie, file to be translated), we have to
express its format, and the corresponding localized files. If possible, I
would like it to be analog with the format used in po-debconf and the gnome
l10n tools.
The following may do the trick:
[<format>] <master_file> <lang>:<localized_file>+
We also need to express where the translation files are (pot+po). In order to
not break the compatibility, the pseudo-format "po4a/paths" could be
introduced.
For example,
[po4a/paths] doc/l10n/project.doc.pot fr:doc/l10n/fr.po de:doc/l10n/de.po
[sgml] doc/my_stuff.sgml fr:doc/fr/mon_truc.sgml de:doc/de/mein_cram.sgml
[pod] script fr:doc/fr/script.1 de:doc/de/script.1
Then, the po4a tool would create a potfile by aggregating the parsed content
of all master files, updating all po files against that file, and then
generate each localized files from each of them.
I guess it would do the trick, but there at least one limitation: we cannot
add addendums in that way. Anyway, the addendums are not very practical right
now, and we may want to change them. One good thing would be to embeed them
into the po file. Having only one file containing all input from translator
would ease the interactions with the developers.
It could be done by dealing specifically with msgids named something
like "po4a-addendum:<filename>:<addendum_count>". In that case, the
translation of this msgid would be an addendum against this file. The header
could be placed into the msgid, also.
Another possible limitation is that all this relies on the fact that the
programes with which I aim at being compatible are smart enough to ignore the
lines for format they don't know about. I didn't check this out. Denis?
If not, it may be a bit artificial.
Yet another limitation is that I have no idea about how to handle module
options...
Once we come up with a configuration file design, doing the actual script
should be rather easy (even if TransTractor also have to be modified to export
some more functions):
parse_config($cfg_file);
# make a big pot
my $potfile=Locale::Po4a::Po->new();
foreach ($format,$master) {
my $doc=Locale::Po4a::Chooser::new($format);
$doc->setpoout($potfile); # trivial function to write, check getpoout
$doc->process('file_in_name' => $master);
$potfile = $doc->getpoout(); # private function to export
}
$potfile->writefile($potfile_name);
# update all po files, just like in po4a-updatepo
# update all translations
foreach ($format,$master,$localized) {
my $doc=Locale::Po4a::Chooser::new($format);
$doc->setpoin($potfile);
$doc->process('file_in_name' => $master,
'file_out_name' => $localized);
}
I didn't test this _at all_, since my hard disk didn't came back to life yet
(tomorow, hopefully). I'm still under webmail, under windows (erk)...
So. What do you guys think about that? Isn't that neat?
Mt.
20 years, 4 months