Skip to content

Commit

Permalink
Allow plonejsi18n accept empty domains when calling.
Browse files Browse the repository at this point in the history
This avoids ``BadRequest`` errors, when being called without a domain url query string.
  • Loading branch information
thet committed Oct 5, 2017
1 parent edb44b6 commit 75d4d89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Bug fixes:

- Fix translations in the delete pop-over
[arsenico13]
- Allow ``plonejsi18n`` accept empty domains when calling.
This avoids ``BadRequest`` errors, when being called without a domain url query string.
[thet]


3.4.4 (2017-08-27)
Expand Down
12 changes: 7 additions & 5 deletions plone/app/content/browser/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def _gettext_catalog(self, domain, language):
catalog = td._data[mo_path]._catalog
return catalog._catalog

def __call__(self, domain, language=None):
def __call__(self, domain=None, language=None):

if domain is None:
return
if language is None:
language = self.request['LANGUAGE']
catalog = {}
else:
if language is None:
language = self.request['LANGUAGE']
catalog = self._gettext_catalog(domain, language)

catalog = self._gettext_catalog(domain, language)
response = self.request.response
response.setHeader('Content-Type', 'application/json; charset=utf-8')
response.setBody(json.dumps(catalog))
Expand Down

0 comments on commit 75d4d89

Please sign in to comment.