Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2e64c348
Kaydet (Commit)
2e64c348
authored
Mar 27, 2002
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Expose C library's gettext. Fixes #516412.
üst
4208d4f7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
4 deletions
+121
-4
liblocale.tex
Doc/lib/liblocale.tex
+18
-0
NEWS
Misc/NEWS
+2
-0
_localemodule.c
Modules/_localemodule.c
+96
-2
configure
configure
+0
-0
configure.in
configure.in
+2
-2
pyconfig.h.in
pyconfig.h.in
+3
-0
No files found.
Doc/lib/liblocale.tex
Dosyayı görüntüle @
2e64c348
...
...
@@ -467,3 +467,21 @@ application doesn't want this to happen, it should remove the
\module
{_
locale
}
extension module (which does all the work) from the
table of built-in modules in the
\file
{
config.c
}
file, and make sure
that the
\module
{_
locale
}
module is not accessible as a shared library.
\subsection
{
Access to message catalogs
}
The locale module exposes the C library's gettext interface on systems
that provide this interface. It consists of the functions
\function
{
gettext
}
,
\function
{
dgettext
}
,
\function
{
dcgettext
}
,
\function
{
textdomain
}
, and
\function
{
bindtextdomain
}
. These are
similar to the same functions in the
\module
{
gettext
}
module, but use
the C library's binary format for message catalogs, and the C
library's search algorithms for locating message catalogs.
Python applications should normally find no need to invoke these
functions, and should use
\module
{
gettext
}
instead. A known exception
to this rule are applications that link use additional C libraries
which internally invoke
\function
{
gettext
}
or
\function
{
dgettext
}
. For
these applications, it may be necessary to bind the text domain, so
that the libraries can properly locate their message catalogs.
Misc/NEWS
Dosyayı görüntüle @
2e64c348
...
...
@@ -31,6 +31,8 @@ Core and builtins
Extension modules
- The locale module now exposes the C library's gettext interface.
- A security hole ("double free") was found in zlib-1.1.3, a popular
third party compression library used by some Python modules. The
hole was quickly plugged in zlib-1.1.4, and the Windows build of
...
...
Modules/_localemodule.c
Dosyayı görüntüle @
2e64c348
...
...
@@ -21,6 +21,10 @@ This software comes with no warranty. Use at your own risk.
#include <langinfo.h>
#endif
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#if defined(MS_WIN32)
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
...
...
@@ -521,7 +525,86 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
return
NULL
;
}
#endif
/* HAVE_LANGINFO_H */
#ifdef HAVE_LIBINTL_H
static
char
gettext__doc__
[]
=
"gettext(msg) -> string
\n
"
"Return translation of msg."
;
static
PyObject
*
PyIntl_gettext
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
in
;
if
(
!
PyArg_ParseTuple
(
args
,
"z"
,
&
in
))
return
0
;
return
PyString_FromString
(
gettext
(
in
));
}
static
char
dgettext__doc__
[]
=
"dgettext(domain, msg) -> string
\n
"
"Return translation of msg in domain."
;
static
PyObject
*
PyIntl_dgettext
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
domain
,
*
in
;
if
(
!
PyArg_ParseTuple
(
args
,
"zz"
,
&
domain
,
&
in
))
return
0
;
return
PyString_FromString
(
dgettext
(
domain
,
in
));
}
static
char
dcgettext__doc__
[]
=
"dcgettext(domain, msg, category) -> string
\n
"
"Return translation of msg in domain and category."
;
static
PyObject
*
PyIntl_dcgettext
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
domain
,
*
msgid
;
int
category
;
if
(
!
PyArg_ParseTuple
(
args
,
"zzi"
,
&
domain
,
&
msgid
,
&
category
))
return
0
;
return
PyString_FromString
(
dcgettext
(
domain
,
msgid
,
category
));
}
static
char
textdomain__doc__
[]
=
"textdomain(domain) -> string
\n
"
"Set the C library's textdmain to domain, returning the new domain."
;
static
PyObject
*
PyIntl_textdomain
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
domain
;
if
(
!
PyArg_ParseTuple
(
args
,
"z"
,
&
domain
))
return
0
;
domain
=
textdomain
(
domain
);
if
(
!
domain
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
return
NULL
;
}
return
PyString_FromString
(
domain
);
}
static
char
bindtextdomain__doc__
[]
=
"bindtextdomain(domain, dir) -> string
\n
"
"Bind the C library's domain to dir."
;
static
PyObject
*
PyIntl_bindtextdomain
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
domain
,
*
dirname
;
if
(
!
PyArg_ParseTuple
(
args
,
"zz"
,
&
domain
,
&
dirname
))
return
0
;
dirname
=
bindtextdomain
(
domain
,
dirname
);
if
(
!
dirname
)
{
PyErr_SetFromErrno
(
PyExc_OSError
);
return
NULL
;
}
return
PyString_FromString
(
dirname
);
}
#endif
static
struct
PyMethodDef
PyLocale_Methods
[]
=
{
{
"setlocale"
,
(
PyCFunction
)
PyLocale_setlocale
,
...
...
@@ -539,7 +622,18 @@ static struct PyMethodDef PyLocale_Methods[] = {
{
"nl_langinfo"
,
(
PyCFunction
)
PyLocale_nl_langinfo
,
METH_VARARGS
,
nl_langinfo__doc__
},
#endif
#ifdef HAVE_LANGINFO_H
{
"gettext"
,(
PyCFunction
)
PyIntl_gettext
,
METH_VARARGS
,
gettext__doc__
},
{
"dgettext"
,(
PyCFunction
)
PyIntl_dgettext
,
METH_VARARGS
,
dgettext__doc__
},
{
"dcgettext"
,(
PyCFunction
)
PyIntl_dcgettext
,
METH_VARARGS
,
dcgettext__doc__
},
{
"textdomain"
,(
PyCFunction
)
PyIntl_textdomain
,
METH_VARARGS
,
textdomain__doc__
},
{
"bindtextdomain"
,(
PyCFunction
)
PyIntl_bindtextdomain
,
METH_VARARGS
,
bindtextdomain__doc__
},
#endif
{
NULL
,
NULL
}
};
...
...
configure
Dosyayı görüntüle @
2e64c348
This diff is collapsed.
Click to expand it.
configure.in
Dosyayı görüntüle @
2e64c348
...
...
@@ -520,8 +520,8 @@ dnl AC_MSG_RESULT($cpp_type)
# checks for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h
locale.h
\
ncurses.h poll.h pthread.h \
AC_CHECK_HEADERS(dlfcn.h fcntl.h grp.h limits.h langinfo.h \
libintl.h locale.h
ncurses.h poll.h pthread.h \
signal.h stdarg.h stddef.h stdlib.h thread.h unistd.h utime.h termios.h \
sys/audioio.h sys/file.h sys/lock.h sys/modem.h db_185.h db.h \
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
...
...
pyconfig.h.in
Dosyayı görüntüle @
2e64c348
...
...
@@ -645,6 +645,9 @@
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <libutil.h> header file. */
#undef HAVE_LIBUTIL_H
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment