hvad.fieldtranslator

hvad.fieldtranslator.TRANSLATIONS

Constant to identify Shared Model classes.

hvad.fieldtranslator.TRANSLATED

Constant to identify Translations Model classes.

hvad.fieldtranslator.NORMAL

Constant to identify normal models.

hvad.fieldtranslator.MODEL_INFO

Caches the model informations in a dictionary with the model class as keys and the return value of _build_model_info() as values.

hvad.fieldtranslator._build_model_info(model)

Builds the model information dictionary for a model. The dictionary holds three keys: 'type', 'shared' and 'translated'. 'type' is one of the constants TRANSLATIONS, TRANSLATED or NORMAL. 'shared' and 'translated' are a list of shared and translated fieldnames. This method is used by get_model_info().

hvad.fieldtranslator.get_model_info(model)

Returns the model information either from the MODEL_INFO cache or by calling _build_model_info().

hvad.fieldtranslator._get_model_from_field(starting_model, fieldname)

Get the model the field fieldname on starting_model is pointing to. This function uses get_field_by_name() on the starting model’s options (meta) to figure out what type of field it is and what the target model is.

hvad.fieldtranslator.translate(querykey, starting_model)

Translates a querykey (eg 'myfield__someotherfield__contains') to be language aware by spanning the translations relations wherever necessary. It also figures out what extra filters to the Translations Model tables are necessary. Returns the translated querykey and a list of language joins which should be used to further filter the queryset with the current language.

Read the Docs v: latest
Versions
latest
0.0.3
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.