LarsVegas
LarsVegas

Reputation: 6832

Django data model for multi language project

I'm setting up a very small and simple django project which will include basically an overview of clients/projects of a translator. So the site obviously should feature the languages the translator translates to or from. Which means there won't be new languages to add in the future. Should I just define everything within one class, something like this:

class project(models.Model):
    project = models.ForeignKey(client)
    title_eng = models.CharField(max_length=50)
    title_pt = models.CharField(max_length=50)
    #...
    body_eng = models.CharField(max_length=250)
    body_pt = models.CharField(max_length=250)
    #...
    time_stamp= models.DateField()  

Do I better use transmeta, which basically does the same? Advantages, disadvantages? A short note of advice is very much appreciated!

Upvotes: 3

Views: 852

Answers (2)

alemangui
alemangui

Reputation: 3655

This question is quite old, but for those who might be looking, make sure to also check django-modeltranslation. It does model translation very simple and it's pretty actively maintained. Docs here

Upvotes: 1

Nate Gentile
Nate Gentile

Reputation: 412

If you want to store your website content in the database you have obviously to store also translations. Basically duplicate text fields in various languages (as you did). Django-transmeta does the same thing for you, and its main advantage is that you can add for example a new language for all your models (or add support for a new field) modifing one line of code (that is actually abstraction layer from the same you did), and syncronizing database. I think it's a good choice.

For the rest I use the Django i18n features, take a look at this, it's a good choice for hard-coded content of your website.

Upvotes: 2

Related Questions