Package: po4a Version: 0.39-1 Tags: patch Currently, split mode is moderately useful, because it is based on the assumption than people want to have their split pofiles as a source for their translations.
The attached patch reuses existing code for split mode, but uses the assumption that the central pofile is the one we want to use for translating (and we keep the central pot around for the same reason). Split pofiles can then be considered as pure products of the po4a run (and manual changes to them are lost - if you don't want that, you want the existing split mode). It can be used eg. as follows: [po4a_paths] $master/l10n/$master.pot $lang:$master/l10n/.$lang.po centralpot:l10n/messages.pot central_$lang:l10n/$lang.po Note that because of the way things are parsed, central_$lang must come last, and centralpot just before it. (a similar comment applies to my patch to #564245)
commit f120ed9011168ec26c0f68602cbf059383d23142 Author: Yann Dirson <[email protected]> Date: Fri Feb 5 15:19:14 2010 +0100 Po4a: add support for 'centralpot:' and 'central_$lang' in po4a_paths declarations. diff --git a/l10n/po4a b/l10n/po4a index 37449fb..7ed9581 100644 --- a/l10n/po4a +++ b/l10n/po4a @@ -704,6 +704,8 @@ my (%aliases); # module aliases ([po4a_alias:...] my ($pot_filename) = ""; my (%po_filename); # po_files: '$lang'=>'$path' my (%document); # '$master'=> {'format'=>'$format'; '$lang'=>'$path'; 'add_$lang'=>('$path','$path') } +my ($central_pot); # central potfile to be kept +my (%central_po); # '$master'=> central pofile to be kept my $doc_count = 0; open CONFIG,"<","$config_file" or die wrap_msg(gettext("Can't open %s: %s"), $config_file, $!); my ($line,$nb) = ("",0); @@ -757,6 +759,21 @@ while (<CONFIG>) { gettext("'%s' redeclared"), "po4a_path") if (length $pot_filename); $pot_filename = $main; + + # Extract lang-specific central catalog. + if ($args =~ m/^(.*?) +(?:central(?:_(.+))?:(\S*))\s*$/) { + $args = $1; + $args = "" unless defined $args; + $central_po{$2} = $3; + } + + # Extract central pot catalog. + if ($args =~ m/^(.*?) +(?:centralpot:(\S*))\s*$/) { + $args = $1; + $args = "" unless defined $args; + $central_pot = $2; + } + foreach my $arg (split(/ /,$args)) { die wrap_ref_mod("$config_file:$nb", "", gettext("Unparsable argument '%s'."), $arg) @@ -1150,6 +1167,12 @@ if ($po4a_opts{"split"}) { chdir $po4a_opts{"calldir"} if (defined $po4a_opts{"srcdir"}); } + # Generate a big pot if required + if (defined $central_pot) { + my $cmd = "msgcat --use-first -o ".$central_pot." ". + join(" ", map { $split_pot{$_} or "" } keys %document); + run_cmd($cmd); + } # Generate a complete .po foreach my $lang (sort keys %po_filename) { my $tmp_bigpo; @@ -1177,7 +1200,11 @@ if ($po4a_opts{"split"}) { run_cmd($cmd_cat); } # We do not need to keep the original name with $master - $po_filename{$lang} = $tmp_bigpo; + if (defined $central_pot and defined $central_po{$lang}) { + $po_filename{$lang} = $central_po{$lang}; + } else { + $po_filename{$lang} = $tmp_bigpo; + } } } @@ -1455,9 +1482,13 @@ if (not $po4a_opts{"no-translations"}) { if ($po4a_opts{"split"}) { chdir $po4a_opts{"srcdir"} if (defined $po4a_opts{"srcdir"}); - # We don't need the tmp big POs anymore - foreach $lang (keys %po_filename) { - unlink $po_filename{$lang}; + unless (defined $central_pot) { + foreach $lang (keys %po_filename) { + unless (defined $central_po{$lang}) { + # That big PO is a tmp one, we don't need it anymore + unlink $po_filename{$lang}; + } + } } chdir $po4a_opts{"calldir"} if (defined $po4a_opts{"srcdir"});

