Skip to content

Commit

Permalink
Merge pull request #33 from terapyon/bugfix/ja-shortname-2901
Browse files Browse the repository at this point in the history
Bugfix shortname status "b" in Japanese
  • Loading branch information
ale-rt authored Jun 27, 2019
2 parents e0849fc + d410286 commit 508af06
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/32.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bugfix Shortname starts "b" in Japanese https://github.com/plone/Products.CMFPlone/issues/2901 [terapyon]
13 changes: 9 additions & 4 deletions plone/i18n/normalizer/ja.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from plone.i18n.normalizer.base import allowed
from plone.i18n.normalizer.interfaces import INormalizer
from zope.interface import implementer
import six


MAX_LENGTH = 6
Expand All @@ -27,9 +28,13 @@ def ja_normalize(text, max_length=MAX_LENGTH):
"""
text = text.strip()
if all(s in allowed for s in text):
return text.encode('ascii')
exchanged = text
else:
return "".join(_gethashed(text, max_length))
exchanged = "".join(_gethashed(text, max_length))
if six.PY2:
return exchanged.encode('ascii')
else:
return exchanged


@implementer(INormalizer)
Expand All @@ -48,8 +53,8 @@ class Normalizer(object):
>>> norm = Normalizer()
>>> text = u"test page"
>>> norm.normalize(text) == b'test page'
True
>>> norm.normalize(text)
'test page'
Text that contains non-ASCII characters are normalized.
Expand Down

0 comments on commit 508af06

Please sign in to comment.