Back to index

plone3  3.1.7
pl.py
Go to the documentation of this file.
00001 # -*- coding: UTF-8 -*-
00002 
00003 from plone.i18n.normalizer.interfaces import INormalizer
00004 from zope.interface import implements
00005 from plone.i18n.normalizer.base import mapUnicode
00006 
00007 # Polish character mapping
00008 mapping = {
00009     321 : 'L', 322 : 'l',
00010 }
00011 
00012 class Normalizer(object):
00013     """
00014     This normalizer can normalize any unicode string and returns a version
00015     that only contains of ASCII characters.
00016 
00017     Let's make sure that this implementation actually fulfills the API.
00018 
00019       >>> from zope.interface.verify import verifyClass
00020       >>> verifyClass(INormalizer, Normalizer)
00021       True
00022 
00023       >>> norm = Normalizer()
00024       >>> norm.normalize(u'\u0141')
00025       'L'
00026     """
00027     implements(INormalizer)
00028 
00029     def normalize(self, text, locale=None, max_length=None):
00030         """
00031         Returns a normalized text. text has to be a unicode string.
00032         """
00033         return mapUnicode(text, mapping=mapping)
00034 
00035 normalizer = Normalizer()