~ubuntu-branches/ubuntu/wily/po4a/wily-proposed

« back to all changes in this revision

Viewing changes to po4a

  • Committer: Bazaar Package Importer
  • Author(s): Nicolas FRANCOIS (Nekral)
  • Date: 2009-04-05 13:45:49 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090405134549-vdbywl1krdhmv4bf
Tags: 0.36.1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /usr/bin/perl
2
 
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
 
1
#! /usr/bin/env perl
 
2
eval 'exec perl -S $0 ${1+"$@"}'
3
3
    if $running_under_some_shell;
4
4
 
5
5
# po4a -- Update both the po files and translated documents in one shoot
6
 
# $Id: po4a,v 1.82 2008-06-01 16:16:33 nekral-guest Exp $
 
6
# $Id: po4a,v 1.86 2009-03-07 12:33:10 nekral-guest Exp $
7
7
#
8
8
# Copyright 2002, 2003, 2004 by Martin Quinson (mquinson#debian.fr)
9
9
#
94
94
 
95
95
 [po4a_paths] doc/$master/$master.pot $lang:doc/$master/$lang.po
96
96
 
 
97
=head2 Autodetection of the paths and languages
 
98
 
 
99
Another command can be used to specify the name of a directory where the
 
100
PO and POT files are located.
 
101
When it is used, po4a will detect the POT file as the only "*.pot" file
 
102
from the specified directory.
 
103
Po4a will also use the list of "*.po" files to define the list of
 
104
languages (by stripping out the extension).
 
105
These languages will be used for the substitution of the $lang variable in
 
106
the rest of the configuration file.
 
107
 
 
108
This command should not be used together with the po4a_langs or po4a_paths
 
109
commands.
 
110
 
 
111
 [po_directory] po4a/po/
 
112
 
97
113
=head2 Specifying the documents to translate
98
114
 
99
115
You now naturally have to specify which documents are translated, their
640
656
          if (@langs);
641
657
        @langs = split(/ /,$main." ".$args);
642
658
 
 
659
    } elsif ($cmd eq "po_directory") {
 
660
        die wrap_ref_mod("$config_file:$nb", "",
 
661
                         gettext("The list of languages cannot be set twice."))
 
662
            if scalar @langs;
 
663
        die wrap_ref_mod("$config_file:$nb", "",
 
664
                         gettext("The POT file cannot be set twice."))
 
665
            if length $pot_filename;
 
666
 
 
667
        my $po_directory = $main;
 
668
        die wrap_ref_mod("$config_file:$nb", "",
 
669
            gettext("'%s' is not a directory"), $po_directory)
 
670
            unless (-d $po_directory);
 
671
        opendir PO_DIR, $po_directory
 
672
            or die wrap_ref_mod("$config_file:$nb", "",
 
673
                   gettext("Cannot list the '%s' directory"), $po_directory);
 
674
 
 
675
        foreach my $f (readdir PO_DIR) {
 
676
            next unless -f "$po_directory/$f";
 
677
            if ($f =~ m/^(.*)\.po$/) {
 
678
                push @langs, $1;
 
679
                $po_filename{$1} = "$po_directory/$f";
 
680
            }
 
681
            if ($f =~ m/\.pot$/) {
 
682
                if (length $pot_filename) {
 
683
                    die wrap_ref_mod("$config_file:$nb", "",
 
684
                        gettext("too many POT files: %s %s"),
 
685
                        $pot_filename, "$po_directory/$f");
 
686
                } else {
 
687
                    $pot_filename = "$po_directory/$f";
 
688
                }
 
689
            }
 
690
        }
 
691
 
 
692
        if (not @langs) {
 
693
            warn wrap_ref_mod("$config_file:$nb", "",
 
694
                 gettext("no PO files found in %s"), $po_directory);
 
695
        }
 
696
 
643
697
    } elsif ($cmd =~ m/type: *(.*)/) {
644
698
        if (defined $document{$main}{'format'}) {
645
699
            warn wrap_ref_mod("$config_file:$nb", "",
713
767
        my %options;
714
768
        my $o = $line;
715
769
        $o =~ s/.*?\[options\] +//;
 
770
        if (defined $document{''}{"options"}) {
 
771
                %options = %{$document{''}{"options"}};
 
772
        }
716
773
        parse_config_options("$config_file:$nb",
717
774
                             $o,
718
 
                             $document{''}{"options"});
 
775
                             \%options);
 
776
        %{$document{''}{"options"}} = %options;
719
777
    } else {
720
778
        die wrap_ref_mod("$config_file:$nb", "",
721
779
            gettext("Unparsable command '%s'."), $cmd);
729
787
 
730
788
sub split_opts {
731
789
    my $options = shift;
 
790
    my $options_orig = $options;
732
791
    my @opts = ();
733
792
    $options =~ s/\\"/"/g;
734
793
    while (length $options) {
735
794
        my $o = "";
736
795
        while (length $options and $options !~ /^ /s) {
 
796
            if (    ($options =~ m/^(["'])/)
 
797
                and ($options !~ m/^(["'])(?:\\.|(?!\1)[^\\])*\1/)) {
 
798
                die wrap_msg(gettext("Cannot parse option line (missing >%s<?): %s"), $1, $options_orig);
 
799
            }
737
800
            # Extract non quoted parts
738
801
            $options =~ s/^([^\\"' ]*)//s;
739
802
            $o .= $1 if defined $1;