mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
update error messages for language and consistency
This commit is contained in:
parent
faf76a4b75
commit
a90ba2bc11
|
@ -36,7 +36,7 @@ class APIException(Exception):
|
||||||
Subclasses should provide `.status_code` and `.default_detail` properties.
|
Subclasses should provide `.status_code` and `.default_detail` properties.
|
||||||
"""
|
"""
|
||||||
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
|
||||||
default_detail = _('A server error occurred')
|
default_detail = _('A server error occurred.')
|
||||||
|
|
||||||
def __init__(self, detail=None):
|
def __init__(self, detail=None):
|
||||||
if detail is not None:
|
if detail is not None:
|
||||||
|
@ -107,7 +107,7 @@ class MethodNotAllowed(APIException):
|
||||||
|
|
||||||
class NotAcceptable(APIException):
|
class NotAcceptable(APIException):
|
||||||
status_code = status.HTTP_406_NOT_ACCEPTABLE
|
status_code = status.HTTP_406_NOT_ACCEPTABLE
|
||||||
default_detail = _('Could not satisfy the request Accept header')
|
default_detail = _('Could not satisfy the request Accept header.')
|
||||||
|
|
||||||
def __init__(self, detail=None, available_renderers=None):
|
def __init__(self, detail=None, available_renderers=None):
|
||||||
if detail is not None:
|
if detail is not None:
|
||||||
|
|
|
@ -640,7 +640,7 @@ class IntegerField(Field):
|
||||||
'invalid': _('A valid integer is required.'),
|
'invalid': _('A valid integer is required.'),
|
||||||
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
||||||
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
||||||
'max_string_length': _('String value too large')
|
'max_string_length': _('String value too large.')
|
||||||
}
|
}
|
||||||
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
||||||
|
|
||||||
|
@ -674,7 +674,7 @@ class FloatField(Field):
|
||||||
'invalid': _("A valid number is required."),
|
'invalid': _("A valid number is required."),
|
||||||
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
'max_value': _('Ensure this value is less than or equal to {max_value}.'),
|
||||||
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
'min_value': _('Ensure this value is greater than or equal to {min_value}.'),
|
||||||
'max_string_length': _('String value too large')
|
'max_string_length': _('String value too large.')
|
||||||
}
|
}
|
||||||
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ class DecimalField(Field):
|
||||||
'max_digits': _('Ensure that there are no more than {max_digits} digits in total.'),
|
'max_digits': _('Ensure that there are no more than {max_digits} digits in total.'),
|
||||||
'max_decimal_places': _('Ensure that there are no more than {max_decimal_places} decimal places.'),
|
'max_decimal_places': _('Ensure that there are no more than {max_decimal_places} decimal places.'),
|
||||||
'max_whole_digits': _('Ensure that there are no more than {max_whole_digits} digits before the decimal point.'),
|
'max_whole_digits': _('Ensure that there are no more than {max_whole_digits} digits before the decimal point.'),
|
||||||
'max_string_length': _('String value too large')
|
'max_string_length': _('String value too large.')
|
||||||
}
|
}
|
||||||
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
MAX_STRING_LENGTH = 1000 # Guard against malicious string inputs.
|
||||||
|
|
||||||
|
@ -793,7 +793,7 @@ class DecimalField(Field):
|
||||||
|
|
||||||
class DateTimeField(Field):
|
class DateTimeField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('Datetime has wrong format. Use one of these formats instead: {format}'),
|
'invalid': _('Datetime has wrong format. Use one of these formats instead: {format}.'),
|
||||||
'date': _('Expected a datetime but got a date.'),
|
'date': _('Expected a datetime but got a date.'),
|
||||||
}
|
}
|
||||||
format = api_settings.DATETIME_FORMAT
|
format = api_settings.DATETIME_FORMAT
|
||||||
|
@ -858,7 +858,7 @@ class DateTimeField(Field):
|
||||||
|
|
||||||
class DateField(Field):
|
class DateField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('Date has wrong format. Use one of these formats instead: {format}'),
|
'invalid': _('Date has wrong format. Use one of these formats instead: {format}.'),
|
||||||
'datetime': _('Expected a date but got a datetime.'),
|
'datetime': _('Expected a date but got a datetime.'),
|
||||||
}
|
}
|
||||||
format = api_settings.DATE_FORMAT
|
format = api_settings.DATE_FORMAT
|
||||||
|
@ -916,7 +916,7 @@ class DateField(Field):
|
||||||
|
|
||||||
class TimeField(Field):
|
class TimeField(Field):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid': _('Time has wrong format. Use one of these formats instead: {format}'),
|
'invalid': _('Time has wrong format. Use one of these formats instead: {format}.'),
|
||||||
}
|
}
|
||||||
format = api_settings.TIME_FORMAT
|
format = api_settings.TIME_FORMAT
|
||||||
input_formats = api_settings.TIME_INPUT_FORMATS
|
input_formats = api_settings.TIME_INPUT_FORMATS
|
||||||
|
@ -1093,8 +1093,7 @@ class FileField(Field):
|
||||||
class ImageField(FileField):
|
class ImageField(FileField):
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'invalid_image': _(
|
'invalid_image': _(
|
||||||
'Upload a valid image. The file you uploaded was either not an '
|
'Upload a valid image. The file you uploaded was either not an image or a corrupted image.'
|
||||||
'image or a corrupted image.'
|
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1118,7 @@ class ListField(Field):
|
||||||
child = None
|
child = None
|
||||||
initial = []
|
initial = []
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'not_a_list': _('Expected a list of items but got type `{input_type}`')
|
'not_a_list': _('Expected a list of items but got type `{input_type}`.')
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
|
@ -119,7 +119,7 @@ class GenericAPIView(views.APIView):
|
||||||
if page == 'last':
|
if page == 'last':
|
||||||
page_number = paginator.num_pages
|
page_number = paginator.num_pages
|
||||||
else:
|
else:
|
||||||
raise Http404(_("Page is not 'last', and cannot be converted to an int."))
|
raise Http404(_("Choose a valid page number. Page numbers must be a whole number, or must be the string 'last'."))
|
||||||
try:
|
try:
|
||||||
page = paginator.page(page_number)
|
page = paginator.page(page_number)
|
||||||
except InvalidPage as exc:
|
except InvalidPage as exc:
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2014-12-31 12:48+0000\n"
|
"POT-Creation-Date: 2014-12-31 13:02+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -30,7 +30,7 @@ msgid "Must include \"username\" and \"password\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/exceptions.py:39
|
#: rest_framework/exceptions.py:39
|
||||||
msgid "A server error occurred"
|
msgid "A server error occurred."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/exceptions.py:74
|
#: rest_framework/exceptions.py:74
|
||||||
|
@ -55,7 +55,7 @@ msgid "Method '%s' not allowed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/exceptions.py:105
|
#: rest_framework/exceptions.py:105
|
||||||
msgid "Could not satisfy the request Accept header"
|
msgid "Could not satisfy the request Accept header."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/exceptions.py:117
|
#: rest_framework/exceptions.py:117
|
||||||
|
@ -92,7 +92,7 @@ msgstr ""
|
||||||
msgid "This field may not be blank."
|
msgid "This field may not be blank."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:548 rest_framework/fields.py:1250
|
#: rest_framework/fields.py:548 rest_framework/fields.py:1249
|
||||||
msgid "Ensure this field has no more than {max_length} characters."
|
msgid "Ensure this field has no more than {max_length} characters."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:640 rest_framework/fields.py:674
|
#: rest_framework/fields.py:640 rest_framework/fields.py:674
|
||||||
#: rest_framework/fields.py:710
|
#: rest_framework/fields.py:710
|
||||||
msgid "String value too large"
|
msgid "String value too large."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:671 rest_framework/fields.py:704
|
#: rest_framework/fields.py:671 rest_framework/fields.py:704
|
||||||
|
@ -155,7 +155,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:793
|
#: rest_framework/fields.py:793
|
||||||
msgid "Datetime has wrong format. Use one of these formats instead: {format}"
|
msgid "Datetime has wrong format. Use one of these formats instead: {format}."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:794
|
#: rest_framework/fields.py:794
|
||||||
|
@ -163,7 +163,7 @@ msgid "Expected a datetime but got a date."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:858
|
#: rest_framework/fields.py:858
|
||||||
msgid "Date has wrong format. Use one of these formats instead: {format}"
|
msgid "Date has wrong format. Use one of these formats instead: {format}."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:859
|
#: rest_framework/fields.py:859
|
||||||
|
@ -171,14 +171,15 @@ msgid "Expected a date but got a datetime."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:916
|
#: rest_framework/fields.py:916
|
||||||
msgid "Time has wrong format. Use one of these formats instead: {format}"
|
msgid "Time has wrong format. Use one of these formats instead: {format}."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:972 rest_framework/fields.py:1016
|
#: rest_framework/fields.py:972 rest_framework/fields.py:1016
|
||||||
msgid "`{input}` is not a valid choice."
|
msgid "`{input}` is not a valid choice."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:1017 rest_framework/serializers.py:474
|
#: rest_framework/fields.py:1017 rest_framework/fields.py:1118
|
||||||
|
#: rest_framework/serializers.py:474
|
||||||
msgid "Expected a list of items but got type `{input_type}`."
|
msgid "Expected a list of items but got type `{input_type}`."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -204,15 +205,15 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/fields.py:1093
|
#: rest_framework/fields.py:1093
|
||||||
msgid "Upload a valid image. The file you uploaded was either not an "
|
msgid ""
|
||||||
msgstr ""
|
"Upload a valid image. The file you uploaded was either not an image or a "
|
||||||
|
"corrupted image."
|
||||||
#: rest_framework/fields.py:1119
|
|
||||||
msgid "Expected a list of items but got type `{input_type}`"
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/generics.py:122
|
#: rest_framework/generics.py:122
|
||||||
msgid "Page is not 'last', and cannot be converted to an int."
|
msgid ""
|
||||||
|
"Choose a valid page number. Page numbers must be a whole number, or must be "
|
||||||
|
"the string 'last'."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: rest_framework/generics.py:126
|
#: rest_framework/generics.py:126
|
||||||
|
|
Loading…
Reference in New Issue
Block a user