A model factory used to create the Translations Model. Makes sure that the unique_together option on the options (meta) contain ('language_code', 'master') as they always have to be unique together. Sets the master foreign key to model onto the Translations Model as well as the language_code field, which is a database indexed char field with a maximum of 15 characters.
Returns the new model.
Gets called from prepare_translatable_model() to set the descriptors of the fields on the Translations Model onto the model.
Gets called from Model‘s metaclass to customize model creation. Performs checks, then contributes translations and translation manager onto models that inherit TranslatableModel.
A wrapper for the translated fields which is set onto TranslatableModel subclasses to define what fields are translated.
Internally this is just used because Django calls the contribute_to_class() method on all attributes of a model, if such a method is available.
Calls create_translations_model().
A baseclass for the models created by create_translations_model() to distinguish Translations Model classes from other models. This model class is abstract.
Deprecated since version 0.5.
Metaclass of TranslatableModel. It is no longer used and should be removed from metaclass inheritance tree in projects.
A model which has translated fields on it. Must define one and exactly one attribute which is an instance of TranslatedFields. This model is abstract.
If initalized with data, it splits the shared and translated fields and prepopulates both the Shared Model and the Translations Model. If no language_code is given, get_language() is used to get the language for the Translations Model instance that gets initialized.
Note
When initializing a TranslatableModel, positional arguments are only supported for the shared fields.
An instance of hvad.manager.TranslationManager.
A list of field on the Shared Model.
A list of field on the Translations Model.
This classmethod is connected to the model’s post save signal from prepare_translatable_model() and saves the cached translation if it’s available.
Initializes a new instance of the Translations Model (does not check the database if one for the language given already exists) and sets it as cached translation. Used by end users to translate instances of a model.
Helper method to safely get a field from the Translations Model.
Helper method to get the cached translation, and in the case the cache for some reason doesnt exist, it gets it from the database.
Returns a list of language codes in which this instance is available.
The options (meta) on BaseTranslationModel subclasses have a few extra attributes holding information about the translations.