[gcompris] Added support for I18N in the new 'findit' activity engine.



commit c752824085a6ccdc95e33708cf5ac2eaee53c8bf
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Tue Mar 22 23:44:15 2011 +0100

    Added support for I18N in the new 'findit' activity engine.

 po/POTFILES.in                                     |    1 +
 src/colors-activity/resources/colors/Makefile.am   |   12 ++-
 .../resources/colors/activity.desktop.in           |  103 ++++++++++++++++++++
 src/colors-activity/resources/colors/activity.txt  |  102 -------------------
 src/findit-activity/findit.py                      |   51 +++++-----
 5 files changed, 141 insertions(+), 128 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 75d8c3b..29ba14e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -170,6 +170,7 @@ src/clockgame-activity/clockgame.c
 src/clockgame-activity/clockgame.xml.in
 src/colors-activity/colors.c
 src/colors-activity/colors.xml.in
+src/colors-activity/resources/colors/activity.desktop.in
 src/connect4-2players-activity/connect4-2players.xml.in
 src/connect4-activity/connect4.py
 src/connect4-activity/connect4.xml.in
diff --git a/src/colors-activity/resources/colors/Makefile.am b/src/colors-activity/resources/colors/Makefile.am
index 4a237f2..d5357a6 100644
--- a/src/colors-activity/resources/colors/Makefile.am
+++ b/src/colors-activity/resources/colors/Makefile.am
@@ -1,6 +1,6 @@
 imgdir = $(pkgdatadir)/@PACKAGE_DATA_DIR@/colors
 img_DATA = \
-	activity.txt \
+	activity.desktop \
 	background.svgz \
 	black_duck.svg \
 	blue_duck.svg \
@@ -13,4 +13,12 @@ img_DATA = \
 	white_duck.svg \
 	yellow_duck.svg
 
-EXTRA_DIST = $(img_DATA)
+# Do not use the INTLTOOL_DESKTOP_RULE, we don't need to embed the translations
+# in the file themselves. GCompris pick the translations from the po file at
+# runtime.
+activity.desktop: activity.desktop.in
+	sed -e "s/^_//g" $< > $@
+
+EXTRA_DIST = $(img_DATA) activity.desktop.in
+
+CLEANFILES = activity.desktop
diff --git a/src/colors-activity/resources/colors/activity.desktop.in b/src/colors-activity/resources/colors/activity.desktop.in
new file mode 100644
index 0000000..c4295cb
--- /dev/null
+++ b/src/colors-activity/resources/colors/activity.desktop.in
@@ -0,0 +1,103 @@
+[common]
+
+objectAreaXYWH=140,50,520,340
+# If you want a rectangle under the objects
+#objectAreaFill=0xCCCCCCAA
+#objectAreaStroke=0xFFFF33AA
+#objectAreaRadiusX=10
+#objectAreaRadiusY=10
+#objectAreaLineWidth=2
+
+objectSelectionFill=0xFF000090
+objectSelectionStroke=0xFFFFFFCC
+
+questionColor=0x000000FF
+questionFont=gcompris/board/title bold
+
+# Provide a text color and font to have it being displayed
+#textColor=0xFFFFFFFF
+#textFont=gcompris/board/big bold
+
+background=background.svgz
+
+# Section maybe [1] or [1.1] to create sublevels
+[1]
+
+questionPosition=400,30
+# Translator: Do not translate {text}.
+_questionText=Find the {text} duck
+questionAudio=voices/$LOCALE/colors/{text}.ogg
+
+okPosition=470,310
+
+object1Image=yellow_duck.svg
+_object1Text=yellow
+object1Audio=voices/$LOCALE/colors/{text}.ogg
+
+object2Image=black_duck.svg
+_object2Text=black
+object2Audio=voices/$LOCALE/colors/{text}.ogg
+
+object3Image=green_duck.svg
+_object3Text=green
+object3Audio=voices/$LOCALE/colors/{text}.ogg
+
+object4Image=red_duck.svg
+_object4Text=red
+object4Audio=voices/$LOCALE/colors/{text}.ogg
+
+object5Image=white_duck.svg
+_object5Text=white
+object5Audio=voices/$LOCALE/colors/{text}.ogg
+
+object6Image=blue_duck.svg
+_object6Text=blue
+object6Audio=voices/$LOCALE/colors/{text}.ogg
+
+[2]
+
+questionPosition=400,30
+_questionText=Find the {text} duck
+questionAudio=voices/$LOCALE/colors/{text}.ogg
+
+okPosition=470,310
+
+object1Image=yellow_duck.svg
+_object1Text=yellow
+object1Audio=voices/$LOCALE/colors/{text}.ogg
+
+object2Image=black_duck.svg
+_object2Text=black
+object2Audio=voices/$LOCALE/colors/{text}.ogg
+
+object3Image=brown_duck.svg
+_object3Text=brown
+object3Audio=voices/$LOCALE/colors/{text}.ogg
+
+object4Image=green_duck.svg
+_object4Text=green
+object4Audio=voices/$LOCALE/colors/{text}.ogg
+
+object5Image=grey_duck.svg
+_object5Text=grey
+object5Audio=voices/$LOCALE/colors/{text}.ogg
+
+object6Image=orange_duck.svg
+_object6Text=orange
+object6Audio=voices/$LOCALE/colors/{text}.ogg
+
+object7Image=purple_duck.svg
+_object7Text=purple
+object7Audio=voices/$LOCALE/colors/{text}.ogg
+
+object8Image=red_duck.svg
+_object8Text=red
+object8Audio=voices/$LOCALE/colors/{text}.ogg
+
+object9Image=white_duck.svg
+_object9Text=white
+object9Audio=voices/$LOCALE/colors/{text}.ogg
+
+object10Image=blue_duck.svg
+_object10Text=blue
+object10Audio=voices/$LOCALE/colors/{text}.ogg
diff --git a/src/findit-activity/findit.py b/src/findit-activity/findit.py
index 8abf148..0258cab 100644
--- a/src/findit-activity/findit.py
+++ b/src/findit-activity/findit.py
@@ -219,7 +219,10 @@ class Gcompris_findit:
       audio = question
     if audio:
       print "play audio=" + audio
-      gcompris.sound.play_ogg(audio)
+      print gcompris.utils.find_file_absolute(audio)
+      gcompris.sound.play_ogg(
+        gcompris.utils.find_file_absolute(audio) )
+
 
   # Return the next question or None if any
   def get_next_question(self):
@@ -240,7 +243,7 @@ class Gcompris_findit:
     try:
       # The question can be formatted with {text} and if so this
       # is replaced by the target name
-      text = datasetlevel.question_text.format(text = object_target.text)
+      text = _(datasetlevel.question_text.format(text = _(object_target.text)))
     except:
       text = datasetlevel.question_text
 
@@ -280,7 +283,7 @@ class Gcompris_findit:
     config = ConfigParser.RawConfigParser()
     p = gcompris.get_properties()
     filename = gcompris.DATA_DIR + '/' + self.gcomprisBoard.name + \
-        '/activity.txt'
+        '/activity.desktop'
     try:
       gotit = config.read(filename)
       if not gotit:
@@ -373,39 +376,39 @@ class finditDataSetLevel:
 
     self.object_area_xywh = \
         map(lambda x: int(x) ,
-            load_common_prop(dataset, section, "object_area_xywh", "").split(','))
-    self.object_area_fill = long(load_common_prop(dataset, section, "object_area_fill", "0"), 16)
-    self.object_area_stroke = long(load_common_prop(dataset, section, "object_area_stroke", "0"), 16)
-    self.object_area_radius_x = int(load_common_prop(dataset, section, "object_area_radius_x", "0"))
-    self.object_area_radius_y = int(load_common_prop(dataset, section, "object_area_radius_y", "0"))
-    self.object_area_line_width = int(load_common_prop(dataset, section, "object_area_line_width", "0"))
+            load_common_prop(dataset, section, "objectAreaXYWH", "").split(','))
+    self.object_area_fill = long(load_common_prop(dataset, section, "objectAreaFill", "0"), 16)
+    self.object_area_stroke = long(load_common_prop(dataset, section, "objectAreaStroke", "0"), 16)
+    self.object_area_radius_x = int(load_common_prop(dataset, section, "objectAreaRadiusX", "0"))
+    self.object_area_radius_y = int(load_common_prop(dataset, section, "objectAreaRadiusY", "0"))
+    self.object_area_line_width = int(load_common_prop(dataset, section, "objectAreaLineWidth", "0"))
 
     self.question_position = \
         map(lambda x: int(x) ,
-            dataset.get(section, "question_position").split(','))
+            dataset.get(section, "questionPosition").split(','))
 
     try:
-      self.question_text = dataset.get(section, "question_text")
+      self.question_text = dataset.get(section, "questionText")
     except:
       self.question_text = None
 
     try:
-      self.question_audio = dataset.get(section, "question_audio")
+      self.question_audio = dataset.get(section, "questionAudio")
     except:
       self.question_audio = None
 
-    self.question_color = long(load_common_prop(dataset, section, "question_color", "0"), 16)
-    self.question_font = load_common_prop(dataset, section, "question_font", "")
+    self.question_color = long(load_common_prop(dataset, section, "questionColor", "0"), 16)
+    self.question_font = load_common_prop(dataset, section, "questionFont", "")
 
     self.ok_position = \
         map(lambda x: int(x) ,
-            dataset.get(section, "ok_position").split(','))
+            dataset.get(section, "okPosition").split(','))
 
     i = 1
     self.objects = []
     while True:
       try:
-        dataset.get(section, "object" + str(i) + "_image")
+        dataset.get(section, "object" + str(i) + "Image")
         self.objects.append(finditDataSetObject(dataset, section, i))
       except:
         break
@@ -434,15 +437,15 @@ class finditDataSetObject:
 
   def __init__(self, dataset, level, index):
     self.index = index
-    self.image = self._load_prop(dataset, level, index, "_image")
-    self.text  = self._load_prop(dataset, level, index, "_text")
-    self.audio = self._load_prop(dataset, level, index, "_audio")
-    self.selection_fill = long(load_common_prop(dataset, level, "object_selection_fill", "0"), 16)
-    self.selection_stroke = long(load_common_prop(dataset, level, "object_selection_stroke", "0"), 16)
-    self.text_color = load_common_prop(dataset, level, "text_color", "")
+    self.image = self._load_prop(dataset, level, index, "Image")
+    self.text  = self._load_prop(dataset, level, index, "Text")
+    self.audio = self._load_prop(dataset, level, index, "Audio")
+    self.selection_fill = long(load_common_prop(dataset, level, "objectSelectionFill", "0"), 16)
+    self.selection_stroke = long(load_common_prop(dataset, level, "objectSelectionStroke", "0"), 16)
+    self.text_color = load_common_prop(dataset, level, "textColor", "")
     if self.text_color:
       self.text_color =  long(self.text_color, 16)
-    self.text_font = load_common_prop(dataset, level, "text_font", "")
+    self.text_font = load_common_prop(dataset, level, "textFont", "")
     self.rootitem = None
     self.item = None
     self.selection = None
@@ -475,7 +478,7 @@ class finditDataSetObject:
     if (self.text_color and self.text_font):
       goocanvas.Text(
         parent = self.rootitem,
-        text = self.text,
+        text = _(self.text),
         x = x + width / 2,
         y = y + height / 2,
         font = gcompris.skin.get_font(self.text_font),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]