adding support for tab-separated translations
Former-commit-id: a51c49dad09ddee57401b0510392ab2e4af64c21
This commit is contained in:
parent
ed8d5404ed
commit
da30e65c29
@ -105,7 +105,7 @@ class DialogPreferences(QtGui.QDialog, gen.preferences_ui.Ui_DialogPreferences):
|
|||||||
self.comboBoxModel.blockSignals(False)
|
self.comboBoxModel.blockSignals(False)
|
||||||
|
|
||||||
allowedTags = {
|
allowedTags = {
|
||||||
'vocab': ['expression', 'reading', 'glossary', 'sentence'],
|
'vocab': ['expression', 'reading', 'glossary', 'sentence','translation'],
|
||||||
'kanji': ['character', 'onyomi', 'kunyomi', 'glossary'],
|
'kanji': ['character', 'onyomi', 'kunyomi', 'glossary'],
|
||||||
}[name]
|
}[name]
|
||||||
|
|
||||||
|
@ -507,9 +507,10 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
|
|||||||
lengthMatched = 0
|
lengthMatched = 0
|
||||||
if self.dockVocab.isVisible():
|
if self.dockVocab.isVisible():
|
||||||
self.state.vocabDefs, lengthMatched = self.language.findTerm(contentSampleFlat)
|
self.state.vocabDefs, lengthMatched = self.language.findTerm(contentSampleFlat)
|
||||||
sentence = reader_util.findSentence(content, samplePosStart)
|
sentence, translation = reader_util.findSentence(content, samplePosStart)
|
||||||
for definition in self.state.vocabDefs:
|
for definition in self.state.vocabDefs:
|
||||||
definition['sentence'] = sentence
|
definition['sentence'] = sentence
|
||||||
|
definition['translation'] = translation
|
||||||
self.updateVocabDefs()
|
self.updateVocabDefs()
|
||||||
|
|
||||||
if self.dockKanji.isVisible():
|
if self.dockKanji.isVisible():
|
||||||
|
@ -78,8 +78,21 @@ def findSentence(content, position):
|
|||||||
quoteStack.pop()
|
quoteStack.pop()
|
||||||
elif c in quotesFwd:
|
elif c in quotesFwd:
|
||||||
quoteStack.insert(0, quotesFwd[c])
|
quoteStack.insert(0, quotesFwd[c])
|
||||||
|
cend = len(content)
|
||||||
return content[start:end].strip()
|
translation_start = 0
|
||||||
|
for i in xrange(end, cend):
|
||||||
|
if content[i] == '\t':
|
||||||
|
translation_start = i+1
|
||||||
|
break
|
||||||
|
translation_end = cend
|
||||||
|
for i in xrange(translation_start, cend):
|
||||||
|
if content[i] == '\n':
|
||||||
|
translation_end = i
|
||||||
|
break
|
||||||
|
translation = ''
|
||||||
|
if translation_start > 0:
|
||||||
|
translation = content[translation_start:translation_end].strip()
|
||||||
|
return content[start:end].strip(), translation
|
||||||
|
|
||||||
|
|
||||||
def formatFields(fields, markup):
|
def formatFields(fields, markup):
|
||||||
|
Loading…
Reference in New Issue
Block a user