Skip to content

Commit

Permalink
Merge pull request #41 from wardi/gettext-encoding-issue
Browse files Browse the repository at this point in the history
Gettext encoding issue
  • Loading branch information
wardi committed Mar 20, 2015
2 parents 535bab1 + ce5b7f0 commit 0cf6616
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ckanext/scheming/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def scheming_language_text(text, prefer_lang=None, _gettext=None):
else:
if _gettext is None:
_gettext = gettext
return _gettext(text)

t = _gettext(text)
if isinstance(t, str):
return t.decode('utf-8')
return t


def scheming_choices_label(choices, value):
Expand Down Expand Up @@ -115,4 +119,3 @@ def scheming_get_organization_schema(organization_type, expanded=True):
schemas = scheming_organization_schemas(expanded)
if schemas:
return schemas.get(organization_type)

4 changes: 4 additions & 0 deletions ckanext/scheming/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def test_first_when_no_matching_language(self):
{'aa': 'hello', 'bb': 'no'},
prefer_lang='en'))

def test_decodes_utf8(self):
assert_equals(u'\xa1Hola!', scheming_language_text('\xc2\xa1Hola!'))


class TestFieldRequired(object):
def test_explicit_required_true(self):
assert_equals(True, scheming_field_required({'required': True}))
Expand Down

0 comments on commit 0cf6616

Please sign in to comment.