Skip to content

Commit

Permalink
Merge pull request #140 from plone/thet-plonejsi18n-graceful
Browse files Browse the repository at this point in the history
Allow ``plonejsi18n`` accept empty domains when calling.
  • Loading branch information
jensens authored Oct 13, 2017
2 parents fe0034c + 75d4d89 commit e790cd8
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]

- Fix and optimize *getVocabulary*-view to work with alternate fulltext
indexes, which don't return brains as search results
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 e790cd8

Please sign in to comment.