Commit fe1fe383 fe1fe3832d7d6febcd163f4854f3a5438db2074c by Wojciech Polak

Add NLS to libmu_py.

* python/libmu_py/nls.c: New file.
* python/mailutils/nls.py: Likewise.
1 parent b390f377
......@@ -42,6 +42,7 @@ libmu_py_la_SOURCES = \
mailcap.c \
message.c \
mime.c \
nls.c \
script.c \
secret.c \
stream.c \
......
......@@ -123,6 +123,7 @@ mu_py_attach_modules (void)
_mu_py_attach_mailcap ();
_mu_py_attach_message ();
_mu_py_attach_mime ();
_mu_py_attach_nls ();
_mu_py_attach_registrar ();
_mu_py_attach_secret ();
_mu_py_attach_stream ();
......
......@@ -40,6 +40,7 @@
#include <mailutils/mime.h>
#include <mailutils/mu_auth.h>
#include <mailutils/mutil.h>
#include <mailutils/nls.h>
#include <mailutils/registrar.h>
#include <mailutils/tls.h>
#include <mailutils/secret.h>
......@@ -73,6 +74,7 @@ extern void _mu_py_attach_mailbox (void);
extern void _mu_py_attach_mailcap (void);
extern void _mu_py_attach_message (void);
extern void _mu_py_attach_mime (void);
extern void _mu_py_attach_nls (void);
extern void _mu_py_attach_registrar (void);
extern void _mu_py_attach_secret (void);
extern void _mu_py_attach_stream (void);
......
/*
GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2009 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
*/
#include "libmu_py.h"
#define PY_MODULE "nls"
static PyObject *
api_nls_init (PyObject *self)
{
mu_init_nls ();
return _ro (Py_None);
}
static PyObject *
api_nls_set_locale (PyObject *self, PyObject *args)
{
int status;
char *lset;
const char *locale;
if (!PyArg_ParseTuple (args, "s", &locale))
return NULL;
lset = mu_set_locale (locale);
return _ro (PyString_FromString (lset ? lset : ""));
}
static PyObject *
api_nls_restore_locale (PyObject *self)
{
mu_restore_locale ();
return _ro (Py_None);
}
static PyMethodDef methods[] = {
{ "init", (PyCFunction) api_nls_init, METH_NOARGS,
"Initialize Native Language Support." },
{ "set_locale", (PyCFunction) api_nls_set_locale, METH_VARARGS,
"Set locale via LC_ALL." },
{ "restore_locale", (PyCFunction) api_nls_restore_locale, METH_NOARGS,
"" },
{ NULL, NULL, 0, NULL }
};
void
_mu_py_attach_nls (void)
{
_mu_py_attach_module (PY_MODULE, methods);
}
......@@ -34,6 +34,7 @@ MU_PY_PKGPYTHON_LIST=\
mailcap.py \
message.py \
mime.py \
nls.py \
registrar.py \
secret.py \
stream.py \
......
......@@ -32,6 +32,7 @@ __all__ = [
"mailcap",
"message",
"mime",
"nls",
"registrar",
"secret",
"stream",
......
#
# GNU Mailutils -- a suite of utilities for electronic mail
# Copyright (C) 2009 Free Software Foundation, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General
# Public License along with this library; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
from mailutils.c_api import nls
def init ():
"""Initialize Native Language Support."""
nls.init ()
def set_locale (locale):
"""Set locale via LC_ALL."""
nls.set_locale (locale)
def restore_locale ():
nls.restore_locale ()