Skip to content

Commit ef56e90

Browse files
committed
Remove new l* functions from original change.
1 parent a351862 commit ef56e90

File tree

2 files changed

+16
-108
lines changed

2 files changed

+16
-108
lines changed

Doc/library/gettext.rst

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ class-based API instead.
4949
.. function:: bind_textdomain_codeset(domain, codeset=None)
5050

5151
Bind the *domain* to *codeset*, changing the encoding of byte strings
52-
returned by the :func:`lgettext`, :func:`ldgettext`, :func:`lngettext`,
53-
:func:`ldngettext`, :func:`lpgettext`, :func:`ldpgettext`,
54-
:func:`lnpgettext`, and :func:`ldnpgettext` functions.
55-
If *codeset* is omitted, then the current binding is returned.
52+
returned by the :func:`lgettext`, :func:`ldgettext`, :func:`lngettext`
53+
and :func:`ldngettext` functions.
5654

5755
.. deprecated-removed:: 3.8 3.10
5856

@@ -113,17 +111,12 @@ class-based API instead.
113111
.. function:: ldgettext(domain, message)
114112
.. function:: lngettext(singular, plural, n)
115113
.. function:: ldngettext(domain, singular, plural, n)
116-
.. function:: lpgettext(context, message)
117-
.. function:: ldpgettext(domain, context, message)
118-
.. function:: lnpgettext(context, singular, plural, n)
119-
.. function:: ldnpgettext(domain, context, singular, plural, n)
120114

121115
Equivalent to the corresponding functions without the ``l`` prefix
122-
(:func:`.gettext`, :func:`dgettext`, :func:`ngettext`, :func:`dngettext`,
123-
:func:`pgettext`, :func:`dpgettext`, :func:`npgettext`, and
124-
:func:`dnpgettext`), but the translation is returned as a byte string
125-
encoded in the preferred system encoding if no other encoding was
126-
explicitly set with :func:`bind_textdomain_codeset`.
116+
(:func:`.gettext`, :func:`dgettext`, :func:`ngettext` and :func:`dngettext`),
117+
but the translation is returned as a byte string encoded in the preferred
118+
system encoding if no other encoding was explicitly set with
119+
:func:`bind_textdomain_codeset`.
127120

128121
.. warning::
129122

@@ -303,13 +296,10 @@ are the methods of :class:`!NullTranslations`:
303296

304297
.. method:: lgettext(message)
305298
.. method:: lngettext(singular, plural, n)
306-
.. method:: lpgettext(context, message)
307-
.. method:: lnpgettext(context, singular, plural, n)
308299

309-
Equivalent to :meth:`.gettext`, :meth:`.ngettext`, :meth:`.pgettext`,
310-
and :meth:`npgettext`, but the translation is returned as a byte string
311-
encoded in the preferred system encoding if no encoding was explicitly
312-
set with :meth:`set_output_charset`.
300+
Equivalent to :meth:`.gettext` and :meth:`.ngettext`, but the translation
301+
is returned as a byte string encoded in the preferred system encoding
302+
if no encoding was explicitly set with :meth:`set_output_charset`.
313303
Overridden in derived classes.
314304

315305
.. warning::
@@ -332,9 +322,8 @@ are the methods of :class:`!NullTranslations`:
332322

333323
.. method:: output_charset()
334324

335-
Return the encoding used to return translated messages in
336-
:meth:`.lgettext`, :meth:`.lngettext`, :meth:`.lpgettext`, and
337-
:meth:`.lnpgettext`.
325+
Return the encoding used to return translated messages in :meth:`.lgettext`
326+
and :meth:`.lngettext`.
338327

339328
.. deprecated-removed:: 3.8 3.10
340329

@@ -354,8 +343,7 @@ are the methods of :class:`!NullTranslations`:
354343
If the *names* parameter is given, it must be a sequence containing the
355344
names of functions you want to install in the builtins namespace in
356345
addition to :func:`_`. Supported names are ``'gettext'``, ``'ngettext'``,
357-
``'pgettext'``, ``'lgettext'``, ``'lngettext'``, ``'lpgettext'``, and
358-
``'lnpgettext'``.
346+
``'pgettext'``, ``'lgettext'``, and ``'lngettext'``.
359347

360348
Note that this is only one way, albeit the most convenient way, to make
361349
the :func:`_` function available to your application. Because it affects
@@ -461,8 +449,6 @@ unexpected, or if other problems occur while reading the file, instantiating a
461449

462450
.. method:: lgettext(message)
463451
.. method:: lngettext(singular, plural, n)
464-
.. method:: lpgettext(context, message)
465-
.. method:: lnpgettext(context, singular, plural, n)
466452

467453
Equivalent to :meth:`.gettext` and :meth:`.ngettext`, but the translation
468454
is returned as a byte string encoded in the preferred system encoding

Lib/gettext.py

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
'dgettext', 'dngettext', 'gettext', 'lgettext', 'ldgettext',
5959
'ldngettext', 'lngettext', 'ngettext',
6060
'pgettext', 'dpgettext', 'npgettext', 'dnpgettext',
61-
'lpgettext', 'ldpgettext', 'lnpgettext', 'ldnpgettext',
6261
]
6362

6463
_default_localedir = os.path.join(sys.base_prefix, 'share', 'locale')
@@ -318,13 +317,6 @@ def pgettext(self, context, message):
318317
return self._fallback.pgettext(context, message)
319318
return message
320319

321-
def lpgettext(self, context, message):
322-
if self._fallback:
323-
return self._fallback.lpgettext(context, message)
324-
if self._output_charset:
325-
return message.encode(self._output_charset)
326-
return message.encode(locale.getpreferredencoding())
327-
328320
def npgettext(self, context, msgid1, msgid2, n):
329321
if self._fallback:
330322
return self._fallback.npgettext(context, msgid1, msgid2, n)
@@ -333,17 +325,6 @@ def npgettext(self, context, msgid1, msgid2, n):
333325
else:
334326
return msgid2
335327

336-
def lnpgettext(self, context, msgid1, msgid2, n):
337-
if self._fallback:
338-
return self._fallback.lnpgettext(context, msgid1, msgid2, n)
339-
if n == 1:
340-
tmsg = msgid1
341-
else:
342-
tmsg = msgid2
343-
if self._output_charset:
344-
return tmsg.encode(self._output_charset)
345-
return tmsg.encode(locale.getpreferredencoding())
346-
347328
def info(self):
348329
return self._info
349330

@@ -366,8 +347,8 @@ def install(self, names=None):
366347
import builtins
367348
builtins.__dict__['_'] = self.gettext
368349
if names is not None:
369-
allowed = {'gettext', 'lgettext', 'lngettext', 'lnpgettext',
370-
'lpgettext', 'ngettext', 'npgettext', 'pgettext'}
350+
allowed = {'gettext', 'lgettext', 'lngettext',
351+
'ngettext', 'npgettext', 'pgettext'}
371352
for name in allowed & set(names):
372353
builtins.__dict__[name] = getattr(self, name)
373354

@@ -549,33 +530,6 @@ def npgettext(self, context, msgid1, msgid2, n):
549530
tmsg = msgid2
550531
return tmsg
551532

552-
def lpgettext(self, context, message):
553-
ctxt_msg_id = self.CONTEXT % (context, message)
554-
missing = object()
555-
tmsg = self._catalog.get(ctxt_msg_id, missing)
556-
if tmsg is missing:
557-
if self._fallback:
558-
return self._fallback.lpgettext(context, message)
559-
tmsg = message
560-
if self._output_charset:
561-
return tmsg.encode(self._output_charset)
562-
return tmsg.encode(locale.getpreferredencoding())
563-
564-
def lnpgettext(self, context, msgid1, msgid2, n):
565-
ctxt_msg_id = self.CONTEXT % (context, msgid1)
566-
try:
567-
tmsg = self._catalog[(ctxt_msg_id, self.plural(n))]
568-
except KeyError:
569-
if self._fallback:
570-
return self._fallback.lnpgettext(context, msgid1, msgid2, n)
571-
if n == 1:
572-
tmsg = msgid1
573-
else:
574-
tmsg = msgid2
575-
if self._output_charset:
576-
return tmsg.encode(self._output_charset)
577-
return tmsg.encode(locale.getpreferredencoding())
578-
579533

580534
# Locate a .mo file using the gettext strategy
581535
def find(domain, localedir=None, languages=None, all=False):
@@ -761,26 +715,15 @@ def ldngettext(domain, msgid1, msgid2, n):
761715

762716
def dpgettext(domain, context, message):
763717
try:
764-
t = translation(domain, _localedirs.get(domain, None),
765-
codeset=_localecodesets.get(domain))
718+
t = translation(domain, _localedirs.get(domain, None))
766719
except OSError:
767720
return message
768721
return t.pgettext(context, message)
769722

770723

771-
def ldpgettext(domain, context, message):
772-
codeset = _localecodesets.get(domain)
773-
try:
774-
t = translation(domain, _localedirs.get(domain, None), codeset=codeset)
775-
except OSError:
776-
return message.encode(codeset or locale.getpreferredencoding())
777-
return t.lpgettext(context, message)
778-
779-
780724
def dnpgettext(domain, context, msgid1, msgid2, n):
781725
try:
782-
t = translation(domain, _localedirs.get(domain, None),
783-
codeset=_localecodesets.get(domain))
726+
t = translation(domain, _localedirs.get(domain, None))
784727
except OSError:
785728
if n == 1:
786729
return msgid1
@@ -789,19 +732,6 @@ def dnpgettext(domain, context, msgid1, msgid2, n):
789732
return t.npgettext(context, msgid1, msgid2, n)
790733

791734

792-
def ldnpgettext(domain, context, msgid1, msgid2, n):
793-
codeset = _localecodesets.get(domain)
794-
try:
795-
t = translation(domain, _localedirs.get(domain, None), codeset=codeset)
796-
except OSError:
797-
if n == 1:
798-
tmsg = msgid1
799-
else:
800-
tmsg = msgid2
801-
return tmsg.encode(codeset or locale.getpreferredencoding())
802-
return t.lnpgettext(context, msgid1, msgid2, n)
803-
804-
805735
def gettext(message):
806736
return dgettext(_current_domain, message)
807737

@@ -834,18 +764,10 @@ def pgettext(context, message):
834764
return dpgettext(_current_domain, context, message)
835765

836766

837-
def lpgettext(context, message):
838-
return ldpgettext(_current_domain, context, message)
839-
840-
841767
def npgettext(context, msgid1, msgid2, n):
842768
return dnpgettext(_current_domain, context, msgid1, msgid2, n)
843769

844770

845-
def lnpgettext(context, msgid1, msgid2, n):
846-
return ldnpgettext(_current_domain, context, msgid1, msgid2, n)
847-
848-
849771
# dcgettext() has been deemed unnecessary and is not implemented.
850772

851773
# James Henstridge's Catalog constructor from GNOME gettext. Documented usage

0 commit comments

Comments
 (0)