[FIX] base: avoid duplicated translations when possible
When modifying a translatable record, we try to keep close translations However, we do not need to do it if there is already a translation for the matched term.
This commit is contained in:
@@ -479,13 +479,18 @@ class ir_translation(osv.osv):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# remap existing translations on terms when possible
|
# remap existing translations on terms when possible
|
||||||
|
trans_src = record_trans.mapped('src')
|
||||||
for trans in record_trans:
|
for trans in record_trans:
|
||||||
if trans.src == trans.value:
|
if trans.src == trans.value:
|
||||||
discarded += trans
|
discarded += trans
|
||||||
elif trans.src not in terms:
|
elif trans.src not in terms:
|
||||||
matches = get_close_matches(trans.src, terms, 1, 0.9)
|
matches = get_close_matches(trans.src, terms, 1, 0.9)
|
||||||
if matches:
|
if matches:
|
||||||
trans.write({'src': matches[0], 'state': trans.state})
|
if matches[0] in trans_src:
|
||||||
|
# there is already a translation for this term; discard this one
|
||||||
|
discarded += trans
|
||||||
|
else:
|
||||||
|
trans.write({'src': matches[0], 'state': trans.state})
|
||||||
else:
|
else:
|
||||||
outdated += trans
|
outdated += trans
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user