Reformat using black
This commit is contained in:
parent
efee4ad081
commit
a87fb49918
221 changed files with 19127 additions and 7310 deletions
|
@ -10,23 +10,25 @@ if settings.USE_I18N:
|
|||
def translation(language):
|
||||
global _translations
|
||||
if language not in _translations:
|
||||
_translations[language] = DjangoTranslation(language, domain='dmoj-user')
|
||||
_translations[language] = DjangoTranslation(language, domain="dmoj-user")
|
||||
return _translations[language]
|
||||
|
||||
def do_translate(message, translation_function):
|
||||
"""Copied from django.utils.translation.trans_real"""
|
||||
# str() is allowing a bytestring message to remain bytestring on Python 2
|
||||
eol_message = message.replace(str('\r\n'), str('\n')).replace(str('\r'), str('\n'))
|
||||
eol_message = message.replace(str("\r\n"), str("\n")).replace(
|
||||
str("\r"), str("\n")
|
||||
)
|
||||
|
||||
if len(eol_message) == 0:
|
||||
# Returns an empty value of the corresponding type if an empty message
|
||||
# is given, instead of metadata, which is the default gettext behavior.
|
||||
result = ''
|
||||
result = ""
|
||||
else:
|
||||
translation_object = translation(get_language())
|
||||
result = getattr(translation_object, translation_function)(eol_message)
|
||||
if not isinstance(result, six.text_type):
|
||||
result = result.decode('utf-8')
|
||||
result = result.decode("utf-8")
|
||||
|
||||
if isinstance(message, SafeData):
|
||||
return mark_safe(result)
|
||||
|
@ -34,7 +36,9 @@ if settings.USE_I18N:
|
|||
return result
|
||||
|
||||
def gettext(message):
|
||||
return do_translate(message, 'gettext')
|
||||
return do_translate(message, "gettext")
|
||||
|
||||
else:
|
||||
|
||||
def gettext(message):
|
||||
return message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue