[gbrainy] Build in a more I18N friendly the list of possible answers for multiple options analogies
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Build in a more I18N friendly the list of possible answers for multiple options analogies
- Date: Sun, 1 May 2011 09:18:42 +0000 (UTC)
commit 2213ba1c9f2f2fa52a070d1db50edc4bfda3ab0e
Author: Jordi Mas <jmas softcatala org>
Date: Sun May 1 11:18:13 2011 +0200
Build in a more I18N friendly the list of possible answers for multiple options analogies
src/Core/Main/Verbal/Analogies.cs | 23 ++++++++++++++++++++
src/Core/Main/Verbal/AnalogiesMultipleOptions.cs | 20 ++--------------
.../Main/Verbal/AnalogiesPairOfWordsOptions.cs | 16 ++-----------
src/Games/Logic/PuzzleCube.cs | 2 +-
4 files changed, 30 insertions(+), 31 deletions(-)
---
diff --git a/src/Core/Main/Verbal/Analogies.cs b/src/Core/Main/Verbal/Analogies.cs
index 7ea5994..f9b12ea 100644
--- a/src/Core/Main/Verbal/Analogies.cs
+++ b/src/Core/Main/Verbal/Analogies.cs
@@ -66,6 +66,29 @@ namespace gbrainy.Core.Main.Verbal
}
}
+ protected string GetMultiOptionsPossibleAnswers ()
+ {
+ switch (Current.answers.Length) {
+ case 0:
+ case 1:
+ throw new InvalidOperationException ("You need more than 1 answer to select from");
+ case 2:
+ // Translators. This is the list of valid answers, like A or B.
+ return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} or {1}"),
+ Answer.GetMultiOption (0), Answer.GetMultiOption (1));
+ case 3:
+ // Translators. This is the list of valid answers, like A, B or C.
+ return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, {1} or {2}"),
+ Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2));
+ case 4:
+ // Translators. This is the list of valid answers, like A, B, C or D.
+ return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0}, {1}, {2} or {3}"),
+ Answer.GetMultiOption (0), Answer.GetMultiOption (1), Answer.GetMultiOption (2), Answer.GetMultiOption (3));
+ default:
+ throw new InvalidOperationException ("Number of multiple options not supported");
+ }
+ }
+
protected void SetAnswerCorrectShow ()
{
if (Current == null ||
diff --git a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
index 5e6cce5..14fa87b 100644
--- a/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesMultipleOptions.cs
@@ -45,30 +45,16 @@ namespace gbrainy.Core.Main.Verbal
public override string Question {
get {
- string str = string.Empty;
-
if (Current == null)
return string.Empty;
if (Current.answers == null)
return Current.question;
- for (int n = 0; n < Current.answers.Length; n++)
- {
- str+= Answer.GetMultiOption (n);
-
- if (n +1 < Current.answers.Length) {
- // Translators: this the separator used when concatenating possible options for answering verbal analogies
- // For example: "Possible correct answers are: a, b, c, d."
- str += ServiceLocator.Instance.GetService <ITranslations> ().GetString (", ");
- }
- }
-
- // Translators: {0} is replaced by a question and {1} by the suggestions on how to answer
- // E.g: What is the correct option? Answer A, B, C.
+ // Translators: {0} is replaced by a question and {1} by the possible valid answers
+ // E.g.: What is the correct option? Answer A, B, C or D.
return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} Answer {1}."),
- Current.question,
- str);
+ Current.question, GetMultiOptionsPossibleAnswers ());
}
}
diff --git a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
index 83de8e7..6ec331a 100644
--- a/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
+++ b/src/Core/Main/Verbal/AnalogiesPairOfWordsOptions.cs
@@ -46,30 +46,20 @@ namespace gbrainy.Core.Main.Verbal
public override string Question {
get {
- string str = string.Empty;
-
if (Current == null)
return string.Empty;
if (Current.answers == null)
return Current.question;
- for (int n = 0; n < Current.answers.Length; n++)
- {
- str+= Answer.GetMultiOption (n);
-
- if (n +1 < Current.answers.Length) {
- str += ServiceLocator.Instance.GetService <ITranslations> ().GetString (", ");
- }
- }
-
string ques = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString (
"Given the relationship between the two words below, which word has the same relationship to '{0}'?"),
sample);
+ // Translators: {0} is replaced by a question and {1} by the possible valid answers
+ // E.g.: What is the correct option? Answer A, B, C or D.
return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("{0} Answer {1}."),
- ques,
- str);
+ ques, GetMultiOptionsPossibleAnswers ());
}
}
diff --git a/src/Games/Logic/PuzzleCube.cs b/src/Games/Logic/PuzzleCube.cs
index fa8f2d6..483747f 100755
--- a/src/Games/Logic/PuzzleCube.cs
+++ b/src/Games/Logic/PuzzleCube.cs
@@ -46,7 +46,7 @@ namespace gbrainy.Games.Logic
}
public override string Question {
- get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("When you fold the figure below as a cube, which face on the figure is opposite the face with a {0} drawn on it? Answer the number written on face."), question);}
+ get {return String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("When you fold the figure below as a cube, which face on the figure is opposite the face with a {0} drawn on it? Answer the number written the on face."), question);}
}
protected override void Initialize ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]