Author: mhutch
Date: 2008-01-25 19:44:17 -0500 (Fri, 25 Jan 2008)
New Revision: 93966
Added:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/StringEscaping.cs
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/ChangeLog
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/Makefile.am
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.mdp
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/Catalog.cs
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/RegexFileScanner.cs
Log:
* MonoDevelop.Gettext.addin.xml,
MonoDevelop.Gettext/RegexFileScanner.cs,
MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs,
MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs,
MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs:
Rework unescaping of C# and XML translatable strings.
* MonoDevelop.Gettext.mdp, Makefile.am: Updated.
* MonoDevelop.Gettext/StringEscaping.cs: Helper class for
escaping/unescaping text.
* MonoDevelop.Gettext/Catalog.cs: Rework escaping of strings.
Fixes "Bug 355967 - Translation issues with regex toolkit descriptions".
Modified: trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/ChangeLog
2008-01-25 23:37:52 UTC (rev 93965)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/ChangeLog
2008-01-26 00:44:17 UTC (rev 93966)
@@ -1,3 +1,17 @@
+2008-01-25 Michael Hutchinson <[EMAIL PROTECTED]>
+
+ * MonoDevelop.Gettext.addin.xml,
MonoDevelop.Gettext/RegexFileScanner.cs,
+ MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs,
+ MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs,
+ MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs:
+ Rework unescaping of C# and XML translatable strings.
+ * MonoDevelop.Gettext.mdp, Makefile.am: Updated.
+ * MonoDevelop.Gettext/StringEscaping.cs: Helper class for
+ escaping/unescaping text.
+ * MonoDevelop.Gettext/Catalog.cs: Rework escaping of strings.
+
+ Fixes "Bug 355967 - Translation issues with regex toolkit descriptions".
+
2008-01-25 Lluis Sanchez Gual <[EMAIL PROTECTED]>
* MonoDevelop.Gettext.addin.xml: Update MD version.
Modified: trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/Makefile.am
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/Makefile.am
2008-01-25 23:37:52 UTC (rev 93965)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/Makefile.am
2008-01-26 00:44:17 UTC (rev 93966)
@@ -56,6 +56,7 @@
MonoDevelop.Gettext/PluralForms.cs \
MonoDevelop.Gettext/PropertyProvider.cs \
MonoDevelop.Gettext/RegexFileScanner.cs \
+ MonoDevelop.Gettext/StringEscaping.cs \
MonoDevelop.Gettext/Translation.cs \
MonoDevelop.Gettext/TranslationProject.cs \
MonoDevelop.Gettext/TranslationProjectOptionsDialog.cs \
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/Catalog.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/Catalog.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/Catalog.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -85,53 +85,81 @@
{
return DateTime.Now.ToString ("yyyy-MM-dd
HH':'mm':'sszz00"); //rfc822 format
}
+
- static string FormatStringForFile (string text)
+ //escapes string and lays it out to 80 cols
+ static void FormatMessageForFile (StringBuilder sb, string
prefix, string message, string newlineChar)
{
- StringBuilder sb = new StringBuilder ();
- uint n_cnt = 0;
- int len = text.Length;
- sb.Append ('"');
- int i = 1;
- if (text.Length > 0 && text[0] != '\n') {
- i = 0;
- } else
- n_cnt++;
- for (; i < len; i++)
- {
- if (text[i] == '"') {
- sb.Append ("\\\"");
- } else if (text[i] == '\\') {
- if (text[i + 1] == 'n') {
- if (i < len - 2) {
- n_cnt++;
- sb.Append ("\\n\"\n\"");
- i++;
- } else {
- sb.Append ("\\n");
- break;
- }
- } else if (text[i + 1] == '"') {
- sb.Append ("\\\"");
- i++;
- } else {
- sb.Append ("\\\\");
+ string escaped = StringEscaping.ToGettextFormat
(message);
+
+ //format to 80 cols
+ //first the simple case: does it fit one one line, with
the prefix, and contain no newlines?
+ if (prefix.Length + escaped.Length < 77 &&
!escaped.Contains ("\\n")) {
+ sb.Append (prefix);
+ sb.Append (" \"");
+ sb.Append (escaped);
+ sb.Append ("\"");
+ sb.Append (newlineChar);
+ return;
+ }
+
+ //not the simple case.
+
+ // first line is typically: prefix ""
+ sb.Append (prefix);
+ sb.Append (" \"\"");
+ sb.Append (newlineChar);
+
+ //followed by 80-col width break on spaces
+ int possibleBreak = -1;
+ int currLineLen = 0;
+ int lastBreakAt = 0;
+ bool forceBreak = false;
+
+ int pos = 0;
+ while (pos < escaped.Length) {
+ char c = escaped[pos];
+
+ //handle escapes
+ if (c == '\\' && pos+1 < escaped.Length) {
+ pos++;
+ currLineLen++;
+
+ char c2 = escaped[pos];
+ if (c2 == 'n') {
+ possibleBreak = pos+1;
+ forceBreak = true;
+ } else if (c2 == 't') {
+ possibleBreak = pos+1;
}
- } else if (text[i] == '\n') {
- sb.Append ("\"\n\"");
- n_cnt++;
- } else {
- sb.Append (text[i]);
}
+
+ if (c == ' ')
+ possibleBreak = pos + 1;
+
+ if (forceBreak || (currLineLen >= 77 &&
possibleBreak != -1)) {
+ sb.Append ("\"");
+ sb.Append (escaped.Substring
(lastBreakAt, possibleBreak - lastBreakAt));
+ sb.Append ("\"");
+ sb.Append (newlineChar);
+
+ //reset state for new line
+ currLineLen = 0;
+ lastBreakAt = possibleBreak;
+ possibleBreak = -1;
+ forceBreak = false;
+ }
+ pos++;
+ currLineLen++;
}
- sb.Append ('"');
-
- // normalize, remove "\n\"\"" lines
- sb.Replace ("\n\"\"", String.Empty);
- if (n_cnt >= 1 && sb.Length > 0)
- return "\"\"\n" + sb.ToString ();
- else
- return sb.ToString ();
+ string remainder = escaped.Substring (lastBreakAt);
+ if (remainder.Length > 0) {
+ sb.Append ("\"");
+ sb.Append (remainder);
+ sb.Append ("\"");
+ sb.Append (newlineChar);
+ }
+ return;
}
// Clears the catalog, removes all entries from it.
@@ -184,7 +212,6 @@
// Saves catalog to file.
public bool Save (string poFile)
{
- string dummy;
StringBuilder sb = new StringBuilder ();
// TODO: check directory
@@ -233,33 +260,22 @@
else
sb.AppendFormat ("#. {0}{1}",
autoComment, originalNewLine);
}
- foreach (string reference in data.References)
- {
+ foreach (string reference in data.References) {
sb.AppendFormat ("#: {0}{1}",
reference, originalNewLine);
}
- dummy = data.Flags;
- if (! String.IsNullOrEmpty (dummy))
- {
- sb.Append (dummy);
+ if (! String.IsNullOrEmpty (data.Flags)) {
+ sb.Append (data.Flags);
sb.Append (originalNewLine);
}
- dummy = Catalog.FormatStringForFile
(data.String);
- Catalog.SaveMultiLines (sb, "msgid " + dummy +
"", originalNewLine);
- if (data.HasPlural)
- {
- dummy = Catalog.FormatStringForFile
(data.PluralString);
- Catalog.SaveMultiLines (sb,
"msgid_plural " + dummy, originalNewLine);
-
- for (int n = 0; n <
data.NumberOfTranslations; n++)
- {
- dummy =
Catalog.FormatStringForFile (data.GetTranslation (n));
- string hdr = String.Format
("msgstr[{0}] ", n);
- SaveMultiLines (sb, hdr +
dummy, originalNewLine);
+ FormatMessageForFile (sb, "msgid", data.String,
originalNewLine);
+ if (data.HasPlural) {
+ FormatMessageForFile (sb,
"msgid_plural", data.PluralString, originalNewLine);
+ for (int n = 0; n <
data.NumberOfTranslations; n++) {
+ string hdr = String.Format
("msgstr[{0}]", n);
+ FormatMessageForFile (sb, hdr,
data.GetTranslation (n), originalNewLine);
}
- } else
- {
- dummy = Catalog.FormatStringForFile
(data.GetTranslation (0));
- SaveMultiLines (sb, "msgstr " + dummy,
originalNewLine);
+ } else {
+ FormatMessageForFile (sb, "msgstr",
data.GetTranslation (0), originalNewLine);
}
sb.Append (originalNewLine);
}
@@ -277,11 +293,10 @@
{
sb.AppendFormat ("#: {0}{1}",
reference, originalNewLine);
}
- dummy = deletedItem.Flags;
- if (! String.IsNullOrEmpty (dummy))
- {
- dummy += originalNewLine;
- sb.Append (dummy);
+ string flags = deletedItem.Flags;
+ if (! String.IsNullOrEmpty (flags)) {
+ sb.Append (flags);
+ sb.Append (originalNewLine);
}
foreach (string deletedLine in
deletedItem.DeletedLines)
{
@@ -735,7 +750,7 @@
#region IEnumerable Members
IEnumerator IEnumerable.GetEnumerator ()
{
- throw new Exception ("This method has not been
implemented.");
+ return entriesList.GetEnumerator ();
}
#endregion
}
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/RegexFileScanner.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/RegexFileScanner.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/RegexFileScanner.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -46,6 +46,7 @@
public Regex Regex;
public int ValueGroupIndex;
public int PluralGroupIndex;
+ public StringEscaping.EscapeMode EscapeMode;
}
class TransformInfo {
@@ -59,18 +60,19 @@
this.mimeTypes = mimeTypes != null ? mimeTypes : new
string[0];
}
- public void AddIncludeRegex (string regex, int valueGroupIndex,
string regexOptions)
+ public void AddIncludeRegex (string regex, int valueGroupIndex,
string regexOptions, StringEscaping.EscapeMode escapeMode)
{
- AddIncludeRegex (regex, valueGroupIndex, -1,
regexOptions);
+ AddIncludeRegex (regex, valueGroupIndex, -1,
regexOptions, escapeMode);
}
- public void AddIncludeRegex (string regex, int valueGroupIndex,
int pluralGroupIndex, string regexOptions)
+ public void AddIncludeRegex (string regex, int valueGroupIndex,
int pluralGroupIndex, string regexOptions, StringEscaping.EscapeMode escapeMode)
{
Regex rx = new Regex (regex, ParseOptions
(regexOptions));
RegexInfo ri = new RegexInfo ();
ri.Regex = rx;
ri.ValueGroupIndex = valueGroupIndex;
ri.PluralGroupIndex = pluralGroupIndex;
+ ri.EscapeMode = escapeMode;
regexes.Add (ri);
}
@@ -92,7 +94,6 @@
RegexOptions ParseOptions (string regexOptions)
{
RegexOptions retval = RegexOptions.Compiled;
- System.Console.WriteLine("Parsing options {0}",
regexOptions);
if (string.IsNullOrEmpty (regexOptions))
return retval;
@@ -172,6 +173,13 @@
foreach (TransformInfo ti in transforms)
mt = ti.Regex.Replace (mt,
ti.ReplaceText);
+ try {
+ mt = StringEscaping.UnEscape
(ri.EscapeMode, mt);
+ } catch (FormatException fex) {
+ monitor.ReportWarning ("Error
unescaping string '" + mt + "': " + fex.Message);
+ continue;
+ }
+
if (mt.Trim().Length == 0)
continue;
Added:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/StringEscaping.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/StringEscaping.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext/StringEscaping.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -0,0 +1,227 @@
+//
+// StringEscaping.cs
+//
+// Author:
+// Michael Hutchinson <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Globalization;
+using System.Text;
+
+namespace MonoDevelop.Gettext
+{
+
+
+ public static class StringEscaping
+ {
+ //based on http://www-ccs.ucsd.edu/c/charset.html
+ //with modififications, as Gettext dosn't follow all C escaping
+ public static string ToGettextFormat (string text)
+ {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < text.Length; i++) {
+ char c = text[i];
+ switch (c) {
+ case '"':
+ sb.Append ("\\\"");
+ continue;
+
+ //Gettext doesn't like escaping this
+ //case '\'':
+ // sb.Append ("\\'");
+ // continue;
+
+ //These shouldn't be in translations... but
will be caught by IsControl
+ //case '\a':
+ //case '\b':
+ //case '\f':
+ //case '\v':
+
+ //this doesn't matter since we're not dealing
with trigraphs
+ //case "?":
+ // sb.Append ("\\?");
+ // continue;
+
+ case '\\':
+ sb.Append ("\\\\");
+ continue;
+ case '\n':
+ sb.Append ("\\n");
+ continue;
+ case '\r':
+ sb.Append ("\\r");
+ continue;
+ case '\t':
+ sb.Append ("\\t");
+ continue;
+ }
+
+ if (char.IsControl (c))
+ throw new FormatException ("Invalid
character in translatable string");
+
+ sb.Append (c);
+ }
+
+ return sb.ToString ();
+ }
+
+ public static string UnEscape (EscapeMode mode, string text)
+ {
+ switch (mode) {
+ case EscapeMode.None:
+ return text;
+ case EscapeMode.CSharp:
+ return FromCSharpFormat (text);
+ case EscapeMode.CSharpVerbatim:
+ return FromCSharpVerbatimFormat (text);
+ case EscapeMode.Xml:
+ return FromXml (text);
+ default:
+ throw new Exception ("Unknown string escaping
mode '" + mode.ToString () + "'");
+ }
+ }
+
+ /*
+ //based on http://www-ccs.ucsd.edu/c/charset.html
+ public static string FromCFormat (string text)
+ {
+ }
+ */
+
+ //based on the C# 2.0 spec
+ static string FromCSharpVerbatimFormat (string text)
+ {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < text.Length; i++) {
+ char c1 = text[i];
+ if (c1 == '"') {
+ i++;
+ char c2 = text[i];
+ if (c2 != '"')
+ throw new FormatException
("Unescaped '\"' character in C# verbatim string.");
+ }
+ sb.Append (c1);
+ }
+ return sb.ToString ();
+ }
+
+ static string FromXml (string text)
+ {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < text.Length; i++) {
+ char c1 = text[i];
+ if (c1 == '&') {
+ int end = text.IndexOf (';', i);
+ if (end == -1)
+ throw new FormatException
("Unterminated XML entity.");
+ string entity = text.Substring (i+1,
end - i - 1);
+ switch (entity) {
+ case "lt":
+ sb.Append ('<');
+ break;
+ case "gt":
+ sb.Append ('>');
+ break;
+ case "amp":
+ sb.Append ('&');
+ break;
+ case "apos":
+ sb.Append ('\'');
+ break;
+ case "quot":
+ sb.Append ('"');
+ break;
+ default:
+ throw new FormatException
("Unrecogised XML entity '&" + entity + ";'.");
+ }
+ i = end;
+ } else
+ sb.Append (c1);
+ }
+ return sb.ToString ();
+ }
+
+ //based on the C# 2.0 spec
+ static string FromCSharpFormat (string text)
+ {
+ StringBuilder sb = new StringBuilder ();
+ for (int i = 0; i < text.Length; i++) {
+ char c1 = text[i];
+ if (c1 != '\\') {
+ sb.Append (c1);
+ continue;
+ }
+
+ i++;
+ char c2 = text[i];
+
+ switch (c2) {
+ case '\'':
+ case '"':
+ case '\\':
+ sb.Append (c2);
+ break;
+ case 'n':
+ sb.Append ('\n');
+ break;
+ case 'r':
+ sb.Append ('\r');
+ break;
+ case 't':
+ sb.Append ('\t');
+ break;
+ case 'U':
+ //FIXME UNICODE
+ //break;
+ case 'u':
+ //FIXME unicode
+ //break;
+ case 'x':
+ //FIXME hex unicode
+ //break;
+ //if (char.IsControl (c);
+
+ //case '0':
+ //case 'a':
+ //case 'b':
+ //case 'f':
+ //case 'v':
+ default:
+ throw new FormatException ("Invalid
escape '\\" + c2 + "' in translatable string.");
+ }
+
+ }
+ return sb.ToString ();
+ }
+
+ public enum EscapeMode
+ {
+ None,
+ CSharp,
+ CSharpVerbatim,
+ Xml
+ }
+ }
+}
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/IncludeExtensionNode.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -26,6 +26,7 @@
//
using System;
+using MonoDevelop.Gettext;
using Mono.Addins;
namespace MonoDevelop.Gettext.ExtensionNodes
@@ -48,6 +49,9 @@
[NodeAttribute ("regexOptions", Description="RegexOptions flags
separated by '|'")]
string regexOptions = null;
+ [NodeAttribute ("escapeMode", Description="If the string is
escaped, this can be used to unescape it using a mode defined in
MonoDevelop.Gettext.StringEscaping.EscapeMode. If more flexibility is needed,
define a Transform regex instead.")]
+ StringEscaping.EscapeMode escapeMode =
StringEscaping.EscapeMode.None;
+
public string RegexValue {
get {
return regexValue;
@@ -71,5 +75,11 @@
return regexOptions;
}
}
+
+ public StringEscaping.EscapeMode EscapeMode {
+ get {
+ return escapeMode;
+ }
+ }
}
}
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/RegexScannerExtensionNode.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -49,7 +49,7 @@
foreach (ExtensionNode node in ChildNodes) {
if (node is IncludeExtensionNode) {
IncludeExtensionNode rn =
(IncludeExtensionNode) node;
- rs.AddIncludeRegex (rn.RegexValue,
rn.Group, rn.PluralGroup, rn.RegexOptions);
+ rs.AddIncludeRegex (rn.RegexValue,
rn.Group, rn.PluralGroup, rn.RegexOptions, rn.EscapeMode);
}
else if (node is ExcludeExtensionNode) {
ExcludeExtensionNode rn =
(ExcludeExtensionNode) node;
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs
2008-01-26 00:44:17 UTC (rev 93966)
@@ -37,12 +37,6 @@
{
RegexFileScanner rs = (RegexFileScanner)
base.CreateInstance ();
rs.AddExcludeRegex ("<!--(?:.|\n)*?-->", null);
- rs.AddTransformRegex (@"\\", @"\\\\", null); // Escape
all backslashes
- rs.AddTransformRegex ("<", "<", null);
- rs.AddTransformRegex (">", ">", null);
- rs.AddTransformRegex ("&", "&", null);
- rs.AddTransformRegex (""", "\"", null);
- rs.AddTransformRegex ("
", "\n", null);
return rs;
}
}
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.addin.xml
2008-01-26 00:44:17 UTC (rev 93966)
@@ -135,11 +135,11 @@
<Extension path = "/MonoDevelop/Gettext/FileScanners">
<XmlRegexScanner extension="glade">
- <Include
regex='translatable\s*=\s*"yes"\s*>([^<]*)<'/>
+ <Include
regex='translatable\s*=\s*"yes"\s*>([^<]*)<' escapeMode="Xml" />
</XmlRegexScanner>
<XmlRegexScanner extension="xml" mimeType="application/xml">
- <Include regex='\s_[-A-Za-z0-9._:]+\s*=\s*"([^"]+)"'/>
- <Include
regex="<_[^>]+>((?:.|\n)*?)</_[^>]+>" />
+ <Include regex='\s_[-A-Za-z0-9._:]+\s*=\s*"([^"]+)"'
escapeMode="Xml" />
+ <Include
regex="<_[^>]+>((?:.|\n)*?)</_[^>]+>" escapeMode="Xml" />
</XmlRegexScanner>
<RegexScanner extension="vb">
<Exclude regex='".*?[^"]"(?!")' /> <!-- Strings-->
@@ -162,9 +162,9 @@
<Exclude regex='(?<!@)".*?(?<!\\)"' /> <!--
Strings-->
<Exclude regex='//(?:(?!//).)*' /> <!-- Line
comments -->
<Exclude regex='/\*(?:.|\n)*?\*/' /> <!--
Block comments -->
- <Include regex='GetString\s*\(\s*"(.*?[^\\])"\s*[,\)]'
regexOptions="Singleline"/>
- <Include
regex='GetPluralString\s*\(\s*"(.*?[^\\])"\s*,\s*"(.*?[^\\])"\s*[,\)]'
plural="true" regexOptions="Singleline"/>
- <Transform regex='([^\\])"\s*\+\s*"' value='$1'
regexOptions="Singleline"/>
+ <Include regex='GetString\s*\(\s*"(.*?[^\\])"\s*[,\)]'
regexOptions="Singleline" escapeMode="CSharp"/>
+ <Include
regex='GetPluralString\s*\(\s*"(.*?[^\\])"\s*,\s*"(.*?[^\\])"\s*[,\)]'
plural="true" regexOptions="Singleline" escapeMode="CSharp"/>
+ <Transform regex='([^\\])"\s*\+\s*"' value='$1'
regexOptions="Singleline"/><!-- strip out "+" concatenations -->
</RegexScanner>
</Extension>
</Addin>
Modified:
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.mdp
===================================================================
---
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.mdp
2008-01-25 23:37:52 UTC (rev 93965)
+++
trunk/monodevelop/main/src/addins/MonoDevelop.Gettext/MonoDevelop.Gettext.mdp
2008-01-26 00:44:17 UTC (rev 93966)
@@ -67,6 +67,7 @@
<File
name="MonoDevelop.Gettext.ExtensionNodes/XmlRegexScannerExtensionNode.cs"
subtype="Code" buildaction="Compile" />
<File name="MonoDevelop.Gettext.ExtensionNodes/ExcludeRegex.cs"
subtype="Code" buildaction="Compile" />
<File name="MonoDevelop.Gettext.ExtensionNodes/TransformExtensionNode.cs"
subtype="Code" buildaction="Compile" />
+ <File name="MonoDevelop.Gettext/StringEscaping.cs" subtype="Code"
buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches