Only after implementation :) Keep in mind, that not only the database
API of Django has to be modified, but also the administration
interface, if we stuck at this solution.

By the way, I forgot to set language in the WHERE clause of my
example, but that makes no big difference for imagining what I had in
mind:
SELECT * FROM myapp_mymodel mm INNER JOIN myapp_mymodel_translatable mmt ON
mm.id = mmt.id WHERE mmt.language = 'EN' ORDER BY title

And also perhaps we need a separate branch for implementation of
multilingual modelling.

Regards,
Aidas Bendoraitis [aka Archatas]



On 11/9/06, Carlos Yoder <[EMAIL PROTECTED]> wrote:
>
> > David Bleweet said:
> >> Actually this could be integrated into the core.
> >> When you create a model, you could add translatable=True to fields
> >> that have to be in the language-specific table.
> >> When you make selections, you would need to set the language name in
> >> the following or a similar way:
> >> MyModel.objects.by_language("EN").all()
> >> MyModel.objects.by_language("EN").order_by('title')
> >> which would form queries like:
> >> SELECT * FROM myapp_mymodel INNER JOIN myapp_mymodel_translatable ON
> >> myapp_mymodel.id = myapp_mymodel_translatable.id ORDER BY title
> >
> > What about using generic relations for this? You could have something
> > like this:
> >
> > class I18NText(models.Model):
> >     language = models.ForeignKey(Language)
> >     field = models.CharField(maxlength=25)
> >     translated_text = models.TextField()
> >
> >     content_type = models.ForeignKey(ContentType)
> >     object_id = models.PositiveIntegerField()
> >     translated_object = models.GenericForeignKey()
> >
> >     def __str__(self):
> >         return self.translated_text
> >
> > class ModelNeedingTranslation(models.Model):
> >     foo = models.IntegerField()
> >     bar = models.TextField()
> >
> >     translations = models.GenericRelation(I18NText)
> >
> > Then you can add translations of field(s) by doing:
> > a = ModelNeedingTranslation(1, 'nothing')
> > a.translations.create(field='bar', translated_text='nada',
> > language=Language('Spanish'))
> >
> > You can get the text for a specific translation like this:
> > a.translations.filter(field='bar', language=Language('Spanish'))
>
> :-O
>
> Would it be really that simple?
>
> --
> Carlos Yoder
> http://blog.argentinaslovenia.com/
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to