summaryrefslogtreecommitdiff
path: root/intltool-extract.in
diff options
context:
space:
mode:
authorDanilo Segan <danilo@canonical.com>2012-01-27 18:31:44 +0100
committerDanilo Segan <danilo@canonical.com>2012-01-27 18:31:44 +0100
commit9c96c2f0997b45ca02b456897088f66ae068c5d1 (patch)
treeaa6fde02fbec97a8661a906fafd456a6b0b85500 /intltool-extract.in
parentcb5885810da54b455bd1bfbed7e964d5db7f676a (diff)
downloadintltool-9c96c2f0997b45ca02b456897088f66ae068c5d1.tar.gz
Strip beginning and ending whitespace and preserve paragraphs for gsettings. Fix submitted by Ryan Lortie.
Diffstat (limited to 'intltool-extract.in')
-rw-r--r--intltool-extract.in22
1 files changed, 21 insertions, 1 deletions
diff --git a/intltool-extract.in b/intltool-extract.in
index 94594eb..c48a9ec 100644
--- a/intltool-extract.in
+++ b/intltool-extract.in
@@ -661,6 +661,13 @@ sub type_schemas {
# Parse the tree as returned by readXml() for gschema.xml files.
sub traverse_gsettings {
+ sub cleanup {
+ s/^\s+//;
+ s/\s+$//;
+ s/\s+/ /g;
+ return $_;
+ }
+
my $nodename = shift;
my $content = shift;
my $comment = shift || 0;
@@ -669,7 +676,20 @@ sub traverse_gsettings {
my %attrs = %{ $attrs_ref };
if (($nodename eq 'default' and $attrs{'l10n'}) or
($nodename eq 'summary') or ($nodename eq 'description')) {
- my $message = getXMLstring($content);
+ # preserve whitespace. deal with it ourselves, below.
+ my $message = getXMLstring($content, 1);
+
+ if ($nodename eq 'default') {
+ # for <default> we strip leading and trailing whitespace but
+ # preserve (possibly quoted) whitespace within
+ $message =~ s/^\s+//;
+ $message =~ s/\s+$//;
+ } else {
+ # for <summary> and <description>, we normalise all
+ # whitespace while preserving paragraph boundaries
+ $message = join "\n\n", map &cleanup, split/\n\n+/, $message;
+ }
+
my $context = $attrs{'context'};
$context =~ s/^["'](.*)["']/$1/ if $context;
$message = $context . "\004" . $message if $context;