Commit c7528240 authored by Bruno Coudoin's avatar Bruno Coudoin

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

parent e2412e28
......@@ -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
......
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
[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
[common]
object_area_xywh = 140,50,520,340
# If you want a rectangle under the objects
#object_area_fill = 0xCCCCCCAA
#object_area_stroke = 0xFFFF33AA
#object_area_radius_x = 10
#object_area_radius_y = 10
#object_area_line_width = 2
object_selection_fill = 0xFF000090
object_selection_stroke = 0xFFFFFFCC
question_color = 0x000000FF
question_font = gcompris/board/title bold
# Provide a text color and font to have it being displayed
#text_color = 0xFFFFFFFF
#text_font = gcompris/board/big bold
background = background.svgz
# Section maybe [1] or [1.1] to create sublevels
[1]
question_position = 400,30
question_text = Find the {text} duck
question_audio = "voices/$LOCALE/colors/{text}.ogg"
ok_position = 470,310
object1_image = yellow_duck.svg
object1_text = yellow
object1_audio = "voices/$LOCALE/colors/{text}.ogg"
object2_image = black_duck.svg
object2_text = black
object2_audio = "voices/$LOCALE/colors/{text}.ogg"
object3_image = green_duck.svg
object3_text = green
object3_audio = "voices/$LOCALE/colors/{text}.ogg"
object4_image = red_duck.svg
object4_text = red
object4_audio = "voices/$LOCALE/colors/{text}.ogg"
object5_image = white_duck.svg
object5_text = white
object5_audio = "voices/$LOCALE/colors/{text}.ogg"
object6_image = blue_duck.svg
object6_text = blue
object6_audio = "voices/$LOCALE/colors/{text}.ogg"
[2]
question_position = 400,30
question_text = Find the {text} duck
question_audio = "voices/$LOCALE/colors/{text}.ogg"
ok_position = 470,310
object1_image = yellow_duck.svg
object1_text = yellow
object1_audio = "voices/$LOCALE/colors/{text}.ogg"
object2_image = black_duck.svg
object2_text = black
object2_audio = "voices/$LOCALE/colors/{text}.ogg"
object3_image = brown_duck.svg
object3_text = brown
object3_audio = "voices/$LOCALE/colors/{text}.ogg"
object4_image = green_duck.svg
object4_text = green
object4_audio = "voices/$LOCALE/colors/{text}.ogg"
object5_image = grey_duck.svg
object5_text = grey
object5_audio = "voices/$LOCALE/colors/{text}.ogg"
object6_image = orange_duck.svg
object6_text = orange
object6_audio = "voices/$LOCALE/colors/{text}.ogg"
object7_image = purple_duck.svg
object7_text = purple
object7_audio = "voices/$LOCALE/colors/{text}.ogg"
object8_image = red_duck.svg
object8_text = red
object8_audio = "voices/$LOCALE/colors/{text}.ogg"
object9_image = white_duck.svg
object9_text = white
object9_audio = "voices/$LOCALE/colors/{text}.ogg"
object10_image = blue_duck.svg
object10_text = blue
object10_audio = "voices/$LOCALE/colors/{text}.ogg"
......@@ -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),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment