Skip to content

Commit

Permalink
Fix i18n API encoding
Browse files Browse the repository at this point in the history
- Make `i18n_js_translations` call `_finish_ok` with an object response data like all the others
- Fix `_finish` and `_finish_ok` documentation to reflect the expected `response_data` type for "json" `content_type`
  • Loading branch information
bzar committed Oct 17, 2018
1 parent e70f6e0 commit 08db954
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ckan/views/api.py
Expand Up @@ -44,7 +44,7 @@ def _finish(status_int, response_data=None,
:param status_int: The HTTP status code to return
:type status_int: int
:param response_data: The body of the response
:type response_data: object if content_type is `text`, a string otherwise
:type response_data: object if content_type is `text` or `json`, a string otherwise
:param content_type: One of `text`, `html` or `json`. Defaults to `text`
:type content_type: string
:param headers: Extra headers to serve with the response
Expand Down Expand Up @@ -82,7 +82,7 @@ def _finish_ok(response_data=None,
calling this method will prepare the response.
:param response_data: The body of the response
:type response_data: object if content_type is `text`, a string otherwise
:type response_data: object if content_type is `text` or `json`, a string otherwise
:param content_type: One of `text`, `html` or `json`. Defaults to `json`
:type content_type: string
:param resource_location: Specify this if a new resource has just been
Expand Down Expand Up @@ -470,7 +470,7 @@ def i18n_js_translations(lang, ver=API_REST_DEFAULT_VERSION):
u'base', u'i18n', u'{0}.js'.format(lang)))
if not os.path.exists(source):
return u'{}'
translations = open(source, u'r').read()
translations = json.load(open(source, u'r'))
return _finish_ok(translations)


Expand Down

0 comments on commit 08db954

Please sign in to comment.