[gbrainy] Fixes bug# 650579
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fixes bug# 650579
- Date: Sat, 27 Aug 2011 10:48:32 +0000 (UTC)
commit 7ba6eccea30924486bacce82ebdfece553117a63
Author: Jordi Mas <jmas softcatala org>
Date: Sat Aug 27 12:47:42 2011 +0200
Fixes bug# 650579
data/games.xml | 5 ++---
src/Core/Main/Xml/GameXmlFactory.cs | 28 ++++++++++++++++++++++++----
2 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/data/games.xml b/data/games.xml
index 217fdda..45e94c8 100644
--- a/data/games.xml
+++ b/data/games.xml
@@ -676,7 +676,7 @@
</option>
<option x = "0.25" y = "0.5" width ="0.6" height ="0.1" order ="randomized">
- <string _text = "[option_prefix] His cousin" x = "0.05" y = "0.02" size = "large"/>
+ <_string msgctxt="John's father's sister's sister-in-law is also?" x = "0.05" y = "0.02" size = "large">[option_prefix] His cousin</_string>
</option>
<option x = "0.25" y = "0.6" width ="0.6" height ="0.1" order ="randomized">
@@ -700,7 +700,7 @@
</option>
<option x = "0.25" y = "0.5" width ="0.6" height ="0.1" order ="randomized">
- <string _text = "[option_prefix] His cousin" x = "0.05" y = "0.02" size = "large"/>
+ <_string msgctxt="John's mother's brother's brother-in-law is also?" x = "0.05" y = "0.02" size = "large">[option_prefix] His cousin</_string>
</option>
<option x = "0.25" y = "0.6" width ="0.6" height ="0.1" order ="randomized">
@@ -709,7 +709,6 @@
<_answer>His father</_answer>
<_rationale>The brother's brother-in-law is John's mother's husband, that is, John's father.</_rationale>
</variant>
-
</game>
<game>
diff --git a/src/Core/Main/Xml/GameXmlFactory.cs b/src/Core/Main/Xml/GameXmlFactory.cs
index 5a5118d..dcf619b 100644
--- a/src/Core/Main/Xml/GameXmlFactory.cs
+++ b/src/Core/Main/Xml/GameXmlFactory.cs
@@ -46,7 +46,9 @@ namespace gbrainy.Core.Main.Xml
string name, str, plural;
bool processing_variant = false;
int variant = 0;
- OptionDrawingObject option = null;
+ OptionDrawingObject option = null;
+ DrawingObject last_drawing_object = null;
+ string last_context = null;
if (read == true)
return;
@@ -56,10 +58,24 @@ namespace gbrainy.Core.Main.Xml
StreamReader stream = new StreamReader (file);
XmlTextReaderLiteral reader = new XmlTextReaderLiteral (stream);
game = null;
-
+
while (reader.Read ())
{
- name = reader.Name.ToLower ();
+ // Strings are only used because msgctxt requirement
+ if (reader.NodeType == XmlNodeType.Text)
+ {
+ const string CONTEXT_GLUE = "\u0004";
+ string text;
+
+ text = reader.ReadString ();
+
+ TextDrawingObject drawing_object = (TextDrawingObject) last_drawing_object;
+ // GetText processes msgctxt as msgctxt + context_glue + text to retrieve them
+ drawing_object.Text = last_context + CONTEXT_GLUE + text;
+ continue;
+ }
+
+ name = reader.Name.ToLower ();
switch (name) {
case "games":
break;
@@ -128,10 +144,12 @@ namespace gbrainy.Core.Main.Xml
break;
case "string":
+ case "_string":
if (reader.NodeType != XmlNodeType.Element)
break;
TextDrawingObject draw_string = new TextDrawingObject ();
+ last_drawing_object = draw_string;
if (option != null)
{
@@ -145,11 +163,13 @@ namespace gbrainy.Core.Main.Xml
game.AddDrawingObject (draw_string);
}
+ last_context = reader.GetAttribute ("msgctxt");
+
draw_string.Text = reader.GetAttribute ("text");
if (String.IsNullOrEmpty (draw_string.Text))
draw_string.Text = reader.GetAttribute ("_text");
-
+
str = reader.GetAttribute ("x");
if (String.IsNullOrEmpty (str) == false)
draw_string.X = Double.Parse (str, CultureInfo.InvariantCulture);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]