Unified searching for translation location and cluster nums back in example translations
This commit is contained in:
@@ -46,40 +46,27 @@ class ShowExampleEdit(ClickMessage):
|
||||
|
||||
class ShowEditTranslation(ClickMessage):
|
||||
def update_model(self, model):
|
||||
# I need to get number of all clusters and cluster of self.arg
|
||||
translation = self.get_arg(0, Translation)
|
||||
for sense in model.entry.senses:
|
||||
num_clusters = len(sense.translations)
|
||||
for cidx, cluster in enumerate(sense.translations):
|
||||
for t in cluster:
|
||||
if t == translation:
|
||||
# fount the one!
|
||||
translation.make_copy()
|
||||
model.modal_set(lambda: modals.edit_translation(
|
||||
translation, (cidx, num_clusters), EditTranslation(translation, cidx)))
|
||||
return
|
||||
|
||||
|
||||
# if here, that his must be example translation
|
||||
# Get translation location
|
||||
(cidx, idx), (parent, cluster) = EditTranslation.get_translation_location(model.entry, translation)
|
||||
|
||||
translation.make_copy()
|
||||
num_clusters = len(parent.translations)
|
||||
model.modal_set(lambda: modals.edit_translation(
|
||||
translation, None, EditTranslation(translation, -1)))
|
||||
translation, cidx, num_clusters, EditTranslation(translation, cidx)))
|
||||
|
||||
|
||||
class ShowAddTranslation(ClickMessage):
|
||||
def update_model(self, model):
|
||||
chosen_sense_or_example = self.get_arg(0)
|
||||
|
||||
if isinstance(chosen_sense_or_example, Sense):
|
||||
cluster = (-1, len(chosen_sense_or_example.translations))
|
||||
else:
|
||||
cluster = None
|
||||
|
||||
translation = Translation.new_empty()
|
||||
translation.make_copy()
|
||||
model.modal_set(lambda: modals.edit_translation(
|
||||
translation,
|
||||
cluster,
|
||||
-1,
|
||||
len(chosen_sense_or_example.translations),
|
||||
AddTranslation(translation, -1, chosen_sense_or_example)))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user