Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84314b7

Browse files
committed
Group consensus is that supporting alternative locale categories is
useless. So the category argument on _find() is removed, as is the dcgettext() function.
1 parent ff6d813 commit 84314b7

1 file changed

Lines changed: 2 additions & 21 deletions

File tree

Lib/gettext.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,13 @@ def _parse(self, fp):
168168
Translations = GNUTranslations
169169

170170
# Locate a .mo file using the gettext strategy
171-
def _find(localedir=None, languages=None, category=None, domain=None):
171+
def _find(localedir=None, languages=None, domain=None):
172172
global _current_domain
173173
global _localedirs
174174

175175
# Get some reasonable defaults for arguments that were not supplied
176176
if domain is None:
177177
domain = _current_domain
178-
if category is None:
179-
category = 'LC_MESSAGES'
180178
if localedir is None:
181179
localedir = _localedirs.get(
182180
domain,
@@ -199,7 +197,7 @@ def _find(localedir=None, languages=None, category=None, domain=None):
199197
for lang in languages:
200198
if lang == 'C':
201199
break
202-
mofile = os.path.join(localedir, lang, category, '%s.mo' % domain)
200+
mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain)
203201
# see if it's in the cache
204202
mo = _translations.get(mofile)
205203
if mo:
@@ -251,23 +249,6 @@ def dgettext(domain, message):
251249
return _find(domain=domain).get(message, message)
252250

253251

254-
def dcgettext(domain, message, category):
255-
try:
256-
from locale import LC_CTYPE, LC_TIME, LC_COLLATE
257-
from locale import LC_MONETARY, LC_MESSAGES, LC_NUMERIC
258-
except ImportError:
259-
return message
260-
categories = {
261-
LC_CTYPE : 'LC_CTYPE',
262-
LC_TIME : 'LC_TIME',
263-
LC_COLLATE : 'LC_COLLATE',
264-
LC_MONETARY : 'LC_MONETARY',
265-
LC_MESSAGES : 'LC_MESSAGES',
266-
LC_NUMERIC : 'LC_NUMERIC'
267-
}
268-
return _find(domain=domain, category=category).get(message, message)
269-
270-
271252

272253
# A higher level API
273254
def set(translation):

0 commit comments

Comments
 (0)