2006-07-04 11:58:45 +08:00
|
|
|
# These are versions of the functions in django.utils.translation.trans_real
|
|
|
|
# that don't actually do anything. This is purely for performance, so that
|
|
|
|
# settings.USE_I18N = False can use this module rather than trans_real.py.
|
|
|
|
|
|
|
|
from django.conf import settings
|
2017-01-27 03:56:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
def gettext(message):
|
|
|
|
return message
|
|
|
|
|
|
|
|
|
|
|
|
gettext_noop = gettext_lazy = _ = gettext
|
2006-07-04 11:58:45 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2006-07-04 11:58:45 +08:00
|
|
|
def ngettext(singular, plural, number):
|
2013-10-17 16:17:41 +08:00
|
|
|
if number == 1:
|
|
|
|
return singular
|
2006-07-04 11:58:45 +08:00
|
|
|
return plural
|
2016-11-13 01:11:23 +08:00
|
|
|
|
|
|
|
|
2006-07-04 11:58:45 +08:00
|
|
|
ngettext_lazy = ngettext
|
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2010-11-04 18:48:27 +08:00
|
|
|
def pgettext(context, message):
|
2017-01-27 03:56:34 +08:00
|
|
|
return gettext(message)
|
2010-11-04 18:48:27 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2010-11-04 18:48:27 +08:00
|
|
|
def npgettext(context, singular, plural, number):
|
2017-01-27 03:56:34 +08:00
|
|
|
return ngettext(singular, plural, number)
|
2010-11-04 18:48:27 +08:00
|
|
|
|
2016-01-24 00:47:07 +08:00
|
|
|
|
|
|
|
def activate(x):
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def deactivate():
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
deactivate_all = deactivate
|
|
|
|
|
|
|
|
|
|
|
|
def get_language():
|
|
|
|
return settings.LANGUAGE_CODE
|
|
|
|
|
|
|
|
|
|
|
|
def get_language_bidi():
|
|
|
|
return settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
|
|
|
|
|
|
|
|
|
|
|
|
def check_for_language(x):
|
|
|
|
return True
|
2006-07-14 10:55:42 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2012-02-18 21:37:30 +08:00
|
|
|
def get_language_from_request(request, check_path=False):
|
2006-07-28 00:38:32 +08:00
|
|
|
return settings.LANGUAGE_CODE
|
2011-06-16 01:29:10 +08:00
|
|
|
|
2013-11-03 07:53:29 +08:00
|
|
|
|
2013-11-12 14:54:01 +08:00
|
|
|
def get_language_from_path(request):
|
2011-06-16 01:29:10 +08:00
|
|
|
return None
|
2017-06-28 07:50:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
def get_supported_language_variant(lang_code, strict=False):
|
|
|
|
if lang_code == settings.LANGUAGE_CODE:
|
|
|
|
return lang_code
|
|
|
|
else:
|
|
|
|
raise LookupError(lang_code)
|