Add more format support like *args #220
Copy link
Copy link
Open
Description
like this:
def gettext(string, *args, **variables):
"""
gettext(u'Hello World!')
gettext(u'Hello %(name)s!', name='World')
gettext(u'Hello %s!', 'World')
"""
t = get_translations()
if t is None:
return string if not variables else string % variables
s = t.ugettext(string)
if args:
return s % args
else:
return s if not variables else s % variables
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
betterlch commentedon Mar 31, 2023
Also,add
"{}".format(*args)support in the same way, it's easy to write the code and tests.betterlch commentedon Mar 31, 2023
like #170
maybe add a new func name
fgettextto support format is better than changing funcgettext