In my design there are some models where I need to store certain fields in different languages. Has it be done before? I saw some Django modules that help do model translations but some of them did not work properly.
Any best practices out there? Below is my code.
My model,
class Lookup_I18n(models.Model):
i18n_code = models.CharField(max_length=5, default=settings.LANGUAGE_CODE)
value = models.CharField(max_length=300)
class Lookup(models.Model):
purpose = models.CharField(max_length=10)
key = models.CharField(max_length=10)
value_i18n = models.ForeignKey(Lookup_I18n)
value = models.Field()
class Meta:
unique_together = (('purpose', 'key'),)
I used recently django_modeltranslation. It will create extra fields in each table for for translation of a field in a certain language. You can provide the translation through Django admin panel. Here are some applications for Django that translate the models. I had to translate just a field in the model and it worked. Choose the application that suits best with your design.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With