Index: po4a =================================================================== RCS file: /cvsroot/po4a/po4a/po4a,v retrieving revision 1.20 diff -u -r1.20 po4a --- po4a 7 Jan 2005 22:50:51 -0000 1.20 +++ po4a 31 Jan 2005 23:36:16 -0000 @@ -49,6 +49,17 @@ 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 template languages + +This is an optional command that can simplify the whole config file, and will +make it more scalable. You have to specify a list of the languages in which +you want to translate the documents. This is as simple as: + + [po4a_langs] fr de + +This will enable you to expand $lang to all the specified languages in the rest +of the config file. + =head2 Specifying the paths to translator inputs First, you have to specify where the translator input files (ie, the files @@ -61,6 +72,11 @@ : +If you've defined the template languages, you can rewrite the line above this +way: + + [po4a_paths] doc/l10n/project.doc.pot $lang:doc/l10n/$lang.po + =head2 Specifying the documents to translate You now naturally have to specify which documents are translated, their @@ -78,6 +94,16 @@ [type: ] :* add_:* +If you've defined the template languages, you can rewrite the line above this +way: + + [type: pod] script $lang:doc/$lang/script.1 add_fr:doc/l10n/script.fr.add + +If all the languages had addendums with similar paths, you could also write +something like: + + [type: pod] script $lang:doc/$lang/script.1 add_$lang:doc/l10n/script.$lang.add + =head1 OPTIONS =over 4 @@ -237,6 +263,7 @@ -e $config_file || die sprintf(gettext("File %s does not exist."),$config_file)."\n"; # Parse the config file +my (@langs); my ($pot_filename) = ""; my (%po_filename); # po_files: '$lang'=>'$path' my (%document); # '$master'=> {'format'=>'$format'; '$lang'=>'$path'; 'add_$lang'=>('$path','$path') } @@ -258,8 +285,27 @@ unless ($line =~ m/^\[([^\]]*)\] (\S+) (.*)$/ || $line =~ m/^\[([^\]]*)\] (\S+)$/); my ($cmd,$main,$args)=($1,$2,$3||""); + if (@langs) { + # Expand the $lang templates + my($args2) = ""; + foreach my $arg (split(/ /,$args)) { + if ( $arg =~ /\$lang/ ) { + # Expand for all the langs + foreach my $lang (@langs) { + my($arg2) = $arg; + $arg2 =~ s/\$lang/$lang/g; + $args2 .= $arg2." "; + } + } else { + # Leave the argument as is + $args2 .= $arg." "; + } + } + $args = $args2; + } + print "cmd=[$cmd]; main=$main; args=\"$args\"\n" if $debug; - + if ($cmd eq "po4a_paths") { die sprintf("%s:%d: ". gettext("'po4a_path' redeclared"). @@ -276,6 +322,14 @@ $po_filename{$1}=$2; } + } elsif ($cmd eq "po4a_langs") { + die sprintf("%s:%d: ". + gettext("'po4a_langs' redeclared"). + "\n", + $config_file,$nb) + if (@langs); + @langs = split(/ /,$main." ".$args); + } elsif ($cmd =~ m/type: *(.*)/) { $document{$main}{'format'} = $1; foreach my $arg (split(/ /,$args)) {