Skip to content

Commit 79b5957

Browse files
committed
Remove deprecated functions from the i18n module
Prior to this change, these functions were deprecated. This change removes the public alias to these functions.
1 parent a8de701 commit 79b5957

1 file changed

Lines changed: 1 addition & 124 deletions

File tree

src/humanize/i18n.py

Lines changed: 1 addition & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Activate, get and deactivate translations."""
22
import gettext as gettext_module
33
import os.path
4-
import warnings
54
from threading import local
65

7-
__all__ = ["activate", "deactivate", "gettext", "ngettext", "thousands_separator"]
6+
__all__ = ["activate", "deactivate", "thousands_separator"]
87

98
_TRANSLATIONS = {None: gettext_module.NullTranslations()}
109
_CURRENT = local()
@@ -79,26 +78,6 @@ def _gettext(message):
7978
return get_translation().gettext(message)
8079

8180

82-
def gettext(message):
83-
"""Get translation.
84-
85-
Args:
86-
message (str): Text to translate.
87-
88-
Returns:
89-
str: Translated text.
90-
91-
WARNING: This function has been deprecated. It is still available as the private
92-
member `_gettext`.
93-
"""
94-
warnings.warn(
95-
"`gettext` has been deprecated. "
96-
"It is still available as the private member `_gettext`.",
97-
DeprecationWarning,
98-
)
99-
return _gettext(message)
100-
101-
10281
def _pgettext(msgctxt, message):
10382
"""Fetches a particular translation.
10483
@@ -124,30 +103,6 @@ def _pgettext(msgctxt, message):
124103
return message if translation == key else translation
125104

126105

127-
def pgettext(msgctxt, message):
128-
"""Fetches a particular translation.
129-
130-
It works with `msgctxt` .po modifiers and allows duplicate keys with different
131-
translations.
132-
133-
Args:
134-
msgctxt (str): Context of the translation.
135-
message (str): Text to translate.
136-
137-
Returns:
138-
str: Translated text.
139-
140-
WARNING: This function has been deprecated. It is still available as the private
141-
member `_pgettext`.
142-
"""
143-
warnings.warn(
144-
"`pgettext` has been deprecated. "
145-
"It is still available as the private member `_pgettext`.",
146-
DeprecationWarning,
147-
)
148-
return _pgettext(msgctxt, message)
149-
150-
151106
def _ngettext(message, plural, num):
152107
"""Plural version of _gettext.
153108
@@ -163,29 +118,6 @@ def _ngettext(message, plural, num):
163118
return get_translation().ngettext(message, plural, num)
164119

165120

166-
def ngettext(msgctxt, message):
167-
"""Plural version of gettext.
168-
169-
Args:
170-
message (str): Singular text to translate.
171-
plural (str): Plural text to translate.
172-
num (str): The number (e.g. item count) to determine translation for the
173-
respective grammatical number.
174-
175-
Returns:
176-
str: Translated text.
177-
178-
WARNING: This function has been deprecated. It is still available as the private
179-
member `_ngettext`.
180-
"""
181-
warnings.warn(
182-
"`ngettext` has been deprecated. "
183-
"It is still available as the private member `_ngettext`.",
184-
DeprecationWarning,
185-
)
186-
return _ngettext(msgctxt, message)
187-
188-
189121
def _gettext_noop(message):
190122
"""Mark a string as a translation string without translating it.
191123
@@ -205,33 +137,6 @@ def num_name(n):
205137
return message
206138

207139

208-
def gettext_noop(message):
209-
"""Mark a string as a translation string without translating it.
210-
211-
Example usage:
212-
```python
213-
CONSTANTS = [_gettext_noop('first'), _gettext_noop('second')]
214-
def num_name(n):
215-
return _gettext(CONSTANTS[n])
216-
```
217-
218-
Args:
219-
message (str): Text to translate in the future.
220-
221-
Returns:
222-
str: Original text, unchanged.
223-
224-
WARNING: This function has been deprecated. It is still available as the private
225-
member `_gettext_noop`.
226-
"""
227-
warnings.warn(
228-
"`gettext_noop` has been deprecated. "
229-
"It is still available as the private member `_gettext_noop`.",
230-
DeprecationWarning,
231-
)
232-
return _gettext_noop(message)
233-
234-
235140
def _ngettext_noop(singular, plural):
236141
"""Mark two strings as pluralized translations without translating them.
237142
@@ -252,34 +157,6 @@ def num_name(n):
252157
return (singular, plural)
253158

254159

255-
def ngettext_noop(singular, plural):
256-
"""Mark two strings as pluralized translations without translating them.
257-
258-
Example usage:
259-
```python
260-
CONSTANTS = [ngettext_noop('first', 'firsts'), ngettext_noop('second', 'seconds')]
261-
def num_name(n):
262-
return _ngettext(*CONSTANTS[n])
263-
```
264-
265-
Args:
266-
singular (str): Singular text to translate in the future.
267-
plural (str): Plural text to translate in the future.
268-
269-
Returns:
270-
tuple: Original text, unchanged.
271-
272-
WARNING: This function has been deprecated. It is still available as the private
273-
member `_ngettext_noop`.
274-
"""
275-
warnings.warn(
276-
"`ngettext_noop` has been deprecated. "
277-
"It is still available as the private member `_ngettext_noop`.",
278-
DeprecationWarning,
279-
)
280-
return _ngettext_noop(singular, plural)
281-
282-
283160
def thousands_separator() -> str:
284161
"""Return the thousands separator for a locale, default to comma.
285162

0 commit comments

Comments
 (0)