views:

131

answers:

3

Hi,

I want to run an article site on several languages, I already translated translation strings, so my templates are ready. I only have a questions how to store articles in many languages? Should I create a database for each translation or it works in different way?

If I have for example this basic model:

class Article(models.Model):
    models.TextField()

And want to store data in many languages, how do I do it? How to organize redirects between one article on different languages

+2  A: 

One simple approach to this problem is to add a "language" field in each model which identifies the language used for each record. This seems to be the approach used by django-pluggable-model-i18n.

Another approach is to use Python metaclasses to identify fields for translation, as used by django-translate and django-transmeta.

There are several other projects but many of them seem abandoned or lower quality. Django-transmeta always seemed the most interesting to me.

Edit: muhuk just wrote an excellent article today reviewing different translation projects: http://www.muhuk.com/2010/01/dynamic-translation-apps-for-django/

Van Gale
A: 

Take a look at how folks at django-cms solved this problem- you can also get your hands dirty and extract the portions of code that are responsible for nice multilingual urls (e.g. url http://site.com/en-us/some_view/ routes correctly to some_view/ and sets request.LANGUAGE_CODE to en-us).

fest
could you show me a short example about urls. how to do it?
Oleg Tarasenko
+1  A: 

There is also: django-multilingual

Tomasz Zielinski
+1: yes, multilingual is a great piece of tool;)
israkir