Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 # Copyright 2005, 2006 Zuza Software Foundation 5 # 6 # This file is part of translate. 7 # 8 # translate is free software; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # 13 # translate is distributed in the hope that it will be useful, 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 # GNU General Public License for more details. 17 # 18 # You should have received a copy of the GNU General Public License 19 # along with translate; if not, write to the Free Software 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 """a set of autocorrect functions that make resolving common problems more automatic...""" 23 24 from translate.filters import decoration 2527 """runs a set of easy automatic corrections""" 28 if msgstr == "": 29 return msgstr 30 if "..." in msgid and u"…" in msgstr: 31 return msgstr.replace(u"…", "...") 32 if decoration.spacestart(msgid) != decoration.spacestart(msgstr) or decoration.spaceend(msgid) != decoration.spaceend(msgstr): 33 return decoration.spacestart(msgid) + msgstr.strip() + decoration.spaceend(msgid) 34 punctuation = (".", ":", ". ", ": ", "?") 35 puncendid = decoration.puncend(msgid, punctuation) 36 puncendstr = decoration.puncend(msgstr, punctuation) 37 if puncendid != puncendstr: 38 if not puncendstr: 39 return msgstr + puncendid 40 if msgid[:1].isalpha() and msgstr[:1].isalpha(): 41 if msgid[:1].isupper() and msgstr[:1].islower(): 42 return msgstr[:1].upper() + msgstr[1:] 43 elif msgid[:1].islower() and msgstr[:1].isupper(): 44 return msgstr[:1].lower() + msgstr[1:] 45 return None4648 """runs a set of easy automatic corrections, handling unicode etc""" 49 if isinstance(msgid, str): 50 msgid = msgid.decode("utf-8") 51 if isinstance(msgstr, str): 52 msgstr = msgstr.decode("utf-8") 53 wasstr = True 54 else: 55 wasstr = False 56 correction = simplecorrect(msgid, msgstr) 57 if correction and wasstr: 58 return correction.encode("utf-8") 59 return correction60
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 26 12:49:44 2008 | http://epydoc.sourceforge.net |