Skip to content

Commit

Permalink
delete old text
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi committed Jul 17, 2019
1 parent d50f837 commit e2a7cb8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions classes/dialog_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def translate(self, cfg):
pnames = [c for c in dir(tr) if c.startswith('Char')]
trs.append(collections.OrderedDict(zip(pnames, tr.getPropertyValues(pnames))))
translated_sentences = lotranslate_backend.translate(cfg, words)
modelCursor.collapseToEnd()
text.insertString(modelCursor, "\n", 0)
modelCursor.setString("")
# import pydevd; pydevd.settrace() # noqa: E702
modelCursor.collapseToEnd()
for translated_words, orig_sent in translated_sentences:
insertedchars = 0
Expand All @@ -179,6 +179,7 @@ def translate(self, cfg):
text.insertTextContent(modelCursor, annot, False)
annot.attach(modelCursor)
modelCursor.collapseToEnd()
text.insertString(modelCursor, " ", 0)
except Exception as e: # noqa: F841
component = desktop.getCurrentComponent()
text = component.Text
Expand Down
2 changes: 2 additions & 0 deletions classes/lotranslate_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def translate(self, text, tokenizer, sentencizer):
input_piece += 1
token_maps[-1].append(input_piece)
pos += thislen
pos += len(sent_split[-1]) # trailing whitespace


src = tokens
src_dir = self.opt.src_dir
Expand Down

0 comments on commit e2a7cb8

Please sign in to comment.