Skip to content

Instantly share code, notes, and snippets.

@mathjazz
Created June 10, 2017 07:44
Show Gist options
  • Select an option

  • Save mathjazz/825ecd1544a34fca7576b747eb96bb35 to your computer and use it in GitHub Desktop.

Select an option

Save mathjazz/825ecd1544a34fca7576b747eb96bb35 to your computer and use it in GitHub Desktop.
ActiveEntityTranslation
Proposal: ActiveEntityTranslation table for faster searching and filtering of entities.
Let's create a table of all active translations. Active translation is a translation that is displayed in the string list (left panel), translation editor (right panel), and as the first item in the History tab. It's either an approved translation, latest suggestion or "None" if the entity hasn't been translated for locale.
I'd like to run this as a quick experiment to see if it can lead us to faster filtering, searching and loading of strings in the translation interface.
Such table will allow us to replace most of the logic in several pieces of pontoon.base.models:
- Entity.get_translation()
- Entity.for_project_locale()
- Entity.map_entities()
- EntityQuerySet class
The table should contain all the data needed for searching, filtering and displaying strings in the UI. The data comes from the Entity and Translation models (and their FKs):
- entity__resource__project__pk
- entity__resource__pk
- entity__resource__path
- entity__resource__format
- entity_pk
- entity_string
- entity_string_plural
- entity_key
- entity_comment
- entity_order
- entity_source
- *entity_status [translated, suggested, fuzzy, missing]
- *entity_has_suggestions [boolean]
- *entity_unchanged [boolean]
- translation__locale__pk
- translation_pk
- translation_string
- translation_plural_form
- translation_user
- translation_date
Fields makred with * are not present in the DB and need to be calculated from other fields on save, e.g. translation_approved, translation_fuzzy and translation_pk (to check if translation exists).
I haven't figured out yet what to do with plurals. The model requires separate ActiveEntityTranslation instance for each plural form. For the purpose of this experiment we acn ignore them, because they are not very common. We could later on completely refactor the model for plurals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment