~hiberis/intltool/bug-904647

« back to all changes in this revision

Viewing changes to intltool-extract.in

  • Committer: Danilo Segan
  • Date: 2012-01-27 17:40:40 UTC
  • mfrom: (726.1.2 bug-922685)
  • Revision ID: danilo@canonical.com-20120127174040-t80ny0f3qwn9x85g
Bug #922685: Keep and normalize paragraphs in gsettings extraction. Strip starting/ending whitespace.  Patch by Ryan Lortie.

Show diffs side-by-side

added added

removed removed

Lines of Context:
661
661
 
662
662
# Parse the tree as returned by readXml() for gschema.xml files.
663
663
sub traverse_gsettings {
 
664
    sub cleanup {
 
665
        s/^\s+//;
 
666
        s/\s+$//;
 
667
        s/\s+/ /g;
 
668
        return $_;
 
669
    }
 
670
 
664
671
    my $nodename = shift;
665
672
    my $content = shift;
666
673
    my $comment = shift || 0;
669
676
    my %attrs = %{ $attrs_ref };
670
677
    if (($nodename eq 'default' and $attrs{'l10n'}) or
671
678
        ($nodename eq 'summary') or ($nodename eq 'description')) {
672
 
        my $message = getXMLstring($content);
 
679
        # preserve whitespace.  deal with it ourselves, below.
 
680
        my $message = getXMLstring($content, 1);
 
681
 
 
682
        if ($nodename eq 'default') {
 
683
            # for <default> we strip leading and trailing whitespace but
 
684
            # preserve (possibly quoted) whitespace within
 
685
            $message =~ s/^\s+//;
 
686
            $message =~ s/\s+$//;
 
687
        } else {
 
688
            # for <summary> and <description>, we normalise all
 
689
            # whitespace while preserving paragraph boundaries
 
690
            $message = join "\n\n", map &cleanup, split/\n\n+/, $message;
 
691
        }
 
692
 
673
693
        my $context = $attrs{'context'};
674
694
        $context =~ s/^["'](.*)["']/$1/ if $context;
675
695
        $message = $context . "\004" . $message if $context;