def parse_file(file): reader = file lineno = 0 catalog = po.catalog() try: (entry,lineno) = parse_entry(reader,lineno) except ParseError: raise ParseError(lineno) catalog.add_entry(entry) content_type = catalog.metadata['Content-Type'] try: charset = re.compile('charset=(.+)$').search(content_type).group(1) if charset == 'CHARSET': charset = 'UTF-8' except: charset = 'UTF-8' while 1: try: (entry,lineno) = parse_entry(reader,lineno) except ParseError as err: raise err if not entry: return catalog #try: # entry.translator_comment = entry.translator_comment.decode(charset) # entry.msgstr = entry.msgstr.decode(charset) # entry.msgid = entry.msgid.decode(charset) #except: # raise ParseError(lineno) catalog.add_entry(entry)
def parse_file(file): reader = file lineno = 0 catalog = po.catalog() try: (entry, lineno) = parse_entry(reader, lineno) except ParseError: raise ParseError(lineno) catalog.add_entry(entry) content_type = catalog.metadata['Content-Type'] try: charset = re.compile('charset=(.+)$').search(content_type).group(1) if charset == 'CHARSET': charset = 'UTF-8' except: charset = 'UTF-8' while 1: try: (entry, lineno) = parse_entry(reader, lineno) except ParseError as err: raise err if not entry: return catalog catalog.add_entry(entry)