Commit dbcd2542 authored by Yves Combe's avatar Yves Combe
Browse files

add gcompris.gcompris_gettext method to call C gettext from python. python...

add gcompris.gcompris_gettext method to call C gettext from python. python gettext does not accept reread it's translation file if environnemnt's LC_MESSAGE is set to a not registered locale. Seems works, but needs more check.
parent a11bfd7c
2005-08-17 Yves Combe <yves@ycombe.net>
add gcompris.gcompris_gettext method to call C gettext from python. python gettext does not accept reread it's translation file if environnemnt's LC_MESSAGE is set to a not registered locale. Seems works, but needs more check.
* src/boards/py-mod-gcompris.c: (py_gcompris_gettext):
* src/boards/python/pythontest.py:
2005-08-17 Yves Combe <yves@ycombe.net>
python bindings, fix name (gcompris_get_locales_list) and bug.
......
......@@ -1336,6 +1336,20 @@ py_gcompris_get_locales_list(PyObject* self, PyObject* args)
static PyObject*
py_gcompris_gettext(PyObject* self, PyObject* args)
{
gchar *text;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "s:gcompris_gettext", &text))
return NULL;
return PyString_FromString(_(text));
}
/****************************************************/
......@@ -1389,6 +1403,7 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "separator", py_gcompris_separator, METH_VARARGS, "gcompris_separator" },
{ "combo_locales", py_gcompris_combo_locales, METH_VARARGS, "gcompris_combo_locales" },
{ "get_locales_list", py_gcompris_get_locales_list, METH_VARARGS, "gcompris_get_locales_list" },
{ "gcompris_gettext", py_gcompris_gettext, METH_VARARGS, "gcompris_gettext" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -6,7 +6,7 @@ import gcompris.utils
import gcompris.skin
import gtk
import gtk.gdk
from gettext import gettext as _
from gcompris import gcompris_gettext as _
class Gcompris_pythontest:
"""Testing gcompris python class"""
......@@ -41,12 +41,16 @@ class Gcompris_pythontest:
self.gcomprisBoard.number_of_sublevel=1
self.config_dict = gcompris.get_board_conf()
self.previous_locale = gcompris.get_locale()
if self.config_dict.has_key('locale'):
gcompris.set_locale(self.config_dict['locale'])
# self.colors['line'] s set in init.
# I put here the configuration use
color_name = self.init_conf('color_line', 'red')
color_name = self.init_conf_str('color_line', 'red')
self.colors['line'] = self.config_colors[color_name]
gcompris.bar_set(0)
......@@ -201,6 +205,8 @@ class Gcompris_pythontest:
def end(self):
gcompris.set_locale(self.previous_locale)
# Remove the root item removes all the others inside it
self.rootitem.destroy()
......
Supports Markdown
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