Index: translate/convert/pot2po.py
===================================================================
--- translate/convert/pot2po.py (revision 7818)
+++ translate/convert/pot2po.py (working copy)
@@ -45,16 +45,19 @@
tmmatcher = match.matcher(tmstore, max_candidates=max_candidates, min_similarity=min_similarity, max_length=max_length)
return tmmatcher
-def convertpot(inputpotfile, outputpofile, templatepofile, tm=None, min_similarity=75, fuzzymatching=True, **kwargs):
+def convertpot(inputpotfile, outputpofile, templatepofile, tm=None, min_similarity=75,
+ fuzzymatching=True, ignore_previous=False, **kwargs):
inputpot = po.pofile(inputpotfile)
templatepo = None
if templatepofile is not None:
templatepo = po.pofile(templatepofile)
- outputpo = convertpot_stores(inputpot, templatepo, tm, min_similarity, fuzzymatching, **kwargs)
+ outputpo = convertpot_stores(inputpot, templatepo, tm, min_similarity,
+ fuzzymatching, ignore_previous, **kwargs)
outputpofile.write(str(outputpo))
return 1
-def convertpot_stores(inputpot, templatepo, tm=None, min_similarity=75, fuzzymatching=True, **kwargs):
+def convertpot_stores(inputpot, templatepo, tm=None, min_similarity=75,
+ fuzzymatching=True, ignore_previous=False, **kwargs):
"""reads in inputpotfile, adjusts header, writes to outputpofile. if templatepofile exists, merge translations from it into outputpofile"""
inputpot.makeindex()
thetargetfile = po.pofile()
@@ -155,8 +158,12 @@
if fuzzyfilematcher:
fuzzycandidates = fuzzyfilematcher.matches(inputpotunit.source)
if fuzzycandidates:
- inputpotunit.merge(fuzzycandidates[0])
original = templatepo.findunit(fuzzycandidates[0].source)
+ if original and not ignore_previous:
+ inputpotunit.set_as_previous()
+ inputpotunit.source = original.source
+ else:
+ inputpotunit.merge(fuzzycandidates[0])
if original:
original.reused = True
if fuzzyglobalmatcher and not fuzzycandidates:
@@ -206,6 +213,10 @@
parser.add_option("--nofuzzymatching", dest="fuzzymatching", action="store_false",
default=True, help="Disable fuzzy matching")
parser.passthrough.append("fuzzymatching")
+ parser.add_option("-g", "--ignore-previous", dest="ignore_previous",
+ action="store_true", default=False,
+ help="Don't keep previous messages")
+ parser.passthrough.append("ignore_previous")
parser.run(argv)