diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2004-07-22 18:44:01 (GMT) |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2004-07-22 18:44:01 (GMT) |
commit | 7bd33c5e22c67e06042fb7ab1186f7587d78153d (patch) | |
tree | 16506bbe1ea96afd7c579802ed92dd1eb8c62a14 /Modules/_localemodule.c | |
parent | 5980ff2d924b55cf963e9fb69f41c86b45f4099a (diff) | |
download | cpython-7bd33c5e22c67e06042fb7ab1186f7587d78153d.zip cpython-7bd33c5e22c67e06042fb7ab1186f7587d78153d.tar.gz cpython-7bd33c5e22c67e06042fb7ab1186f7587d78153d.tar.bz2 |
This change implements the following gettext features, as
discussed recently in python-dev:
In _locale module:
- bind_textdomain_codeset() binding
In gettext module:
- bind_textdomain_codeset() function
- lgettext(), lngettext(), ldgettext(), ldngettext(),
which return translated strings encoded in
preferred system encoding, if
bind_textdomain_codeset() was not used.
- Added equivalent functionality in translate()
function and catalog classes.
Every change was also documented.
Diffstat (limited to 'Modules/_localemodule.c')
-rw-r--r-- | Modules/_localemodule.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 0f8a71a..2d6541d 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -649,6 +649,24 @@ PyIntl_bindtextdomain(PyObject* self,PyObject*args) return PyString_FromString(dirname); } +#ifdef HAVE_BIND_TEXTDOMAIN_CODESET +PyDoc_STRVAR(bind_textdomain_codeset__doc__, +"bind_textdomain_codeset(domain, codeset) -> string\n" +"Bind the C library's domain to codeset."); + +static PyObject* +PyIntl_bind_textdomain_codeset(PyObject* self,PyObject*args) +{ + char *domain,*codeset; + if (!PyArg_ParseTuple(args, "sz", &domain, &codeset)) + return NULL; + codeset = bind_textdomain_codeset(domain, codeset); + if (codeset) + return PyString_FromString(codeset); + Py_RETURN_NONE; +} +#endif + #endif static struct PyMethodDef PyLocale_Methods[] = { @@ -678,6 +696,10 @@ static struct PyMethodDef PyLocale_Methods[] = { textdomain__doc__}, {"bindtextdomain",(PyCFunction)PyIntl_bindtextdomain,METH_VARARGS, bindtextdomain__doc__}, +#ifdef HAVE_BIND_TEXTDOMAIN_CODESET + {"bind_textdomain_codeset",(PyCFunction)PyIntl_bind_textdomain_codeset, + METH_VARARGS, bind_textdomain_codeset__doc__}, +#endif #endif {NULL, NULL} }; |