Translate from a new non-primary language page

16 views
Skip to first unread message

jeroen.pulles

unread,
Jan 13, 2012, 7:02:27 AM1/13/12
to Django FeinCMS
Hi,

I have a website with five languages. Dutch is set as "primary
language" per the settings.LANGUAGE_CODE setting. When I create a new
page in the English-language tree and then add a Dutch translation of
that page, I get an error:

AttributeError: 'NoneType' object has no attribute 'id'

The original_translation property is called on the English page and
returns None, because English is not the primary language and the
English page doesn't have the translation_of field set. Wouldn't it
make more sense to assume that a Page with a translation_of_id of None
is the original_translation?

kind regards,
Jeroen

Matthias Kestenholz

unread,
Jan 16, 2012, 10:25:32 AM1/16/12
to django-...@googlegroups.com
Hi Jeroen

Not necessarily, no. The current way of doing it ensures a few things:

- Pages in the primary language always have translation_of_id=None
- Pages in secondary languages may have translation_of set, but the
pointed-at object is always the primary language translation

This makes it much easier and more efficient to determine all
available translations. If you allow arbitrary translations for
translation_of you'll have to walk translation chains to collect all
translations of a certain page. You might need len(LANGUAGES) SQL
queries in the worst case to collect all translation objects. We
wanted to avoid that.

That being said, it seems you hit a real bug.


Matthias

Martin J. Laubach

unread,
Jan 16, 2012, 10:55:26 AM1/16/12
to django-...@googlegroups.com
  But what is the desired result of original_translation when there is no original translation? We could probably fudge it to return the current page, but that's not quite correct and I'm not sure what will happen if we do. Should we just try?

        mjl

Wouter van der Graaf

unread,
Jan 17, 2012, 4:04:02 AM1/17/12
to Django FeinCMS
Hi there,

So, what if I have multiple languages with Dutch as primary and I want
to set a German page's translate_of to an English page, because there
is no Dutch page applicable? That's not possible, right? So to be able
to reference any translation to any other page there must always be a
primary Dutch page? That means there's not much flexibility in
creating different content trees for many languages, where you might
want to cluster languages in common content groups.

What would be viable to gain this feature? If it means a little
performance loss, I could live with that. In all projects I did with
FeinCMS the need for this flexibility is much higher than the need for
raw performance in FeinCMS. Couldn't proper caching of translation
structures help mitigate the performance loss?

If there's no way to have this flexibility, isn't it possible to
automatically swap translation direction in Jeroen's case? Consider
these steps:

1. Dutch is my primary language.
2. I create a new English page that has no Dutch (primary) equivalent,
so translation_of is None.
3. Later on I naively decide to create a Dutch page with
translation_of set to the English page (which is wrong to the system,
but right in my logic).
4. Upon saving the page we check that this is the primary language
with translation_of set to a secondary language. Yes, this is the
case, so set the secondary page's translation_of field to the primary
page and remove translation_of from the primary page.
5. Now the situation is correct to both my logic and the system.

Wouter

jeroen.pulles

unread,
Jan 17, 2012, 3:15:14 PM1/17/12
to Django FeinCMS
Hi,

I wrote a little patch/workaround that 'works for me':

<https://github.com/jeroenp/feincms/commit/
5a6c347bf6cf50aa7987533e9e04739f85b96f95>

This look ugly to me, though, especially since translations is
considered an extension to Page and I'm mucking about in Page. But I'm
new to FeinCMS so I probably very ignorant of lots of details. Sorry
about that ;-)

I'm wondering if the solution doesn't lie in the changelist generation
of links. When creating the translations for/of links there, it's
already known that this page is not in the primary language and does
not have an original translation. Why not create a different query
string argument than 'translation_of' there.

kind regards,
Jeroen
Reply all
Reply to author
Forward
0 new messages