diff options
-rw-r--r-- | intltool-extract.in | 24 | ||||
-rw-r--r-- | tests/cases/extract8.glade | 14 | ||||
-rw-r--r-- | tests/cases/gsettings.gschema.xml | 44 | ||||
-rw-r--r-- | tests/results/extract8.glade.h | 3 | ||||
-rw-r--r-- | tests/results/gsettings.gschema.xml.h | 9 |
5 files changed, 90 insertions, 4 deletions
diff --git a/intltool-extract.in b/intltool-extract.in index 94594eb..5afc292 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\s*\n+/, $message; + } + my $context = $attrs{'context'}; $context =~ s/^["'](.*)["']/$1/ if $context; $message = $context . "\004" . $message if $context; @@ -827,7 +847,7 @@ sub type_glade { } ## handle new glade files - while ($input =~ /<(property|atkproperty|col)\s+[^>]*translatable\s*=\s*"yes"(?:\s+[^>]*context\s*=\s*"([^"]*)")?(?:\s+[^>]*comments\s*=\s*"([^"]*)")?[^>]*>([^<]+)<\/\1>/sg) { + while ($input =~ /<(\w+)\s+[^>]*translatable\s*=\s*"yes"(?:\s+[^>]*context\s*=\s*"([^"]*)")?(?:\s+[^>]*comments\s*=\s*"([^"]*)")?[^>]*>([^<]+)<\/\1>/sg) { if (!($4 =~ /^(window|label)[0-9]+$/)) { my $message = entity_decode($4); if (defined($2)) { diff --git a/tests/cases/extract8.glade b/tests/cases/extract8.glade index cf5188c..fc37b1c 100644 --- a/tests/cases/extract8.glade +++ b/tests/cases/extract8.glade @@ -2,6 +2,20 @@ <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd" > <glade-interface> + <menu id='app-menu'> + <section> + <item> + <attribute name="label" translatable="yes">_New Window</attribute> + </item> + <item> + <attribute name="label" translatable="yes">_New Tab</attribute> + </item> + </section> + <section> + <attribute name="label" translatable="yes">_Quit</attribute> + </section> + </menu> + <widget class="GtkWindow" id="window1"> <property name="title" translatable="yes">Testing</property> <property name="border_width">10</property> diff --git a/tests/cases/gsettings.gschema.xml b/tests/cases/gsettings.gschema.xml index f3ad749..c88b169 100644 --- a/tests/cases/gsettings.gschema.xml +++ b/tests/cases/gsettings.gschema.xml @@ -4,14 +4,54 @@ <key name="dpi" type="i"> <default>96</default> <summary context="Dots Per Inch">DPI</summary> - <description>The resolution used for converting font sizes to pixel sizes, in dots per inch.</description> + <description> + The resolution used for converting font sizes to pixel sizes, in + dots per inch. + </description> + </key> + <key name="translated-default" type="s"> + <default l10n='messages'> + 'space preserved properly' + </default> + </key> + <key name="complicated" type="i"> + <default>0</default> + <summary> + This is a complicated key. + </summary> + <description context='GSettings description'> + This key is very complicated. You should not attempt to + understand it. + + There was this one guy who attempted to make sense of it once. + We don't know what happened to him. + </description> </key> <key name="clocktype" type="i"> <!-- Translators: translate to either 12 or 24 to define the default clock format. --> <default l10n="messages" context="clock-format">24</default> <summary>Time format</summary> - <description context="Time format gsettings description">How many hours can you tell apart?</description> + <description context="Time format gsettings description"> + How many hours can you tell apart? + </description> + </key> + <key name="newline-normalization" type="i"> + <default>0</default> + <summary> + This is a key with multiple newlines. + </summary> + <description context='GSettings description'> + Paragraph one. Please keep the whitespace indentation in empty + lines for testing as well. + + + +
+ + Paragraph two. There was never anyone who + tried to make sense out of this. + </description> </key> </schema> </schemalist> diff --git a/tests/results/extract8.glade.h b/tests/results/extract8.glade.h index fd82e2a..f5d13a8 100644 --- a/tests/results/extract8.glade.h +++ b/tests/results/extract8.glade.h @@ -1,3 +1,6 @@ +char *s = N_("_New Window"); +char *s = N_("_New Tab"); +char *s = N_("_Quit"); char *s = N_("Testing"); /* Comment on <property> tag */ char *s = N_("A label"); diff --git a/tests/results/gsettings.gschema.xml.h b/tests/results/gsettings.gschema.xml.h index bbd4138..0140c9d 100644 --- a/tests/results/gsettings.gschema.xml.h +++ b/tests/results/gsettings.gschema.xml.h @@ -1,7 +1,16 @@ char *s = C_("Dots Per Inch", "DPI"); char *s = N_("The resolution used for converting font sizes to pixel sizes, in dots per inch."); +char *s = N_("'space preserved properly'"); +char *s = N_("This is a complicated key."); +char *s = C_("GSettings description", "This key is very complicated. You should not attempt to understand it.\n" + "\n" + "There was this one guy who attempted to make sense of it once. We don't know what happened to him."); /* Translators: translate to either 12 or 24 to define the default clock format. */ char *s = C_("clock-format", "24"); char *s = N_("Time format"); char *s = C_("Time format gsettings description", "How many hours can you tell apart?"); +char *s = N_("This is a key with multiple newlines."); +char *s = C_("GSettings description", "Paragraph one. Please keep the whitespace indentation in empty lines for testing as well.\n" + "\n" + "Paragraph two. There was never anyone who tried to make sense out of this."); |