mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
[i18n] Make Json error messages translatable.
This commit is contained in:
@@ -316,7 +316,7 @@ def authenticated_rest_api_view(view_func):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return json_error(_("Invalid authorization header for basic auth"))
|
return json_error(_("Invalid authorization header for basic auth"))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return json_unauthorized("Missing authorization header for basic auth")
|
return json_unauthorized(_("Missing authorization header for basic auth"))
|
||||||
|
|
||||||
# Now we try to do authentication or die
|
# Now we try to do authentication or die
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
from django.views.decorators.csrf import csrf_exempt, csrf_protect
|
||||||
|
|
||||||
from zerver.decorator import authenticated_json_view, authenticated_rest_api_view, \
|
from zerver.decorator import authenticated_json_view, authenticated_rest_api_view, \
|
||||||
@@ -82,7 +84,7 @@ def rest_dispatch(request, globals_list, **kwargs):
|
|||||||
# browser, send the user to the login page
|
# browser, send the user to the login page
|
||||||
return HttpResponseRedirect('%s/?next=%s' % (settings.HOME_NOT_LOGGED_IN, request.path))
|
return HttpResponseRedirect('%s/?next=%s' % (settings.HOME_NOT_LOGGED_IN, request.path))
|
||||||
else:
|
else:
|
||||||
return json_unauthorized("Not logged in: API authentication or user session required")
|
return json_unauthorized(_("Not logged in: API authentication or user session required"))
|
||||||
|
|
||||||
if request.method not in ["GET", "POST"]:
|
if request.method not in ["GET", "POST"]:
|
||||||
# process_as_post needs to be the outer decorator, because
|
# process_as_post needs to be the outer decorator, because
|
||||||
|
|||||||
Reference in New Issue
Block a user