[Python-checkins] python/dist/src/Modules _localemodule.c, 2.47, 2.48

niemeyer at users.sourceforge.net niemeyer at users.sourceforge.net
Thu Jul 22 20:44:04 CEST 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3065/Modules

Modified Files:
	_localemodule.c 
Log Message:
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.


Index: _localemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_localemodule.c,v
retrieving revision 2.47
retrieving revision 2.48
diff -C2 -d -r2.47 -r2.48
*** _localemodule.c	15 Jul 2004 13:31:39 -0000	2.47
--- _localemodule.c	22 Jul 2004 18:44:01 -0000	2.48
***************
*** 650,653 ****
--- 650,671 ----
  }
  
+ #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
  
***************
*** 679,682 ****
--- 697,704 ----
    {"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}



More information about the Python-checkins mailing list