try: from Products import PlacelessTranslationService PLACELESS = 1 except ImportError: PLACELESS = 0 def translate(context,msgid,default='', domain='Krihvel', target='', mapping={}): """ translate """ if not PLACELESS: if default: return default else: return msgid pts = PlacelessTranslationService.getTranslationService() v = pts.utranslate(domain='iva',msgid=msgid, mapping=mapping, context=context, default=msgid, target_language=target) return v.encode('utf-8') def to_unicode(s,encoding='utf-8'): import types from types import UnicodeType if type(s)==UnicodeType: return s try: return unicode(s,encoding) except UnicodeError: return unicode(s,'iso-8859-1')