Kotti_multilingual and kotti_calendar

31 views
Skip to first unread message

Anders Nylund

unread,
Jun 21, 2016, 11:56:18 AM6/21/16
to Kotti
The whole kotti/pyramid/sqlalchemy stack is completely new to me, but it looks like a neat system well worth learning. I'm trying to build a small cms site with two requirements, multilingual and an event calendar. I understand that kotti_multilingual is a work in progress, but that it should be useful already.

First roadblock is that it doesn't look like it's possible to select a language, instead you navigate to a language specific part of the tree. That works fine I suppose, but then the first page of the site is always some kind of 'select your language' page. Shouldn't it be possible for a visitor to select his language just once, and only change it if he really wants to?

Then when you navigate to a language root, the menu will show what's one level below the language root, but not the language root itself. To navigate back to the language root you then need navigate to the first page and select language again.

Adding a calendar to a document below a language root and translating the calendar creates a copy on the second language branch, and then events can be created on both calendars and translated into the other, which works fine. But the calendar can't be added directly to the language root, only to a document below it. What if I want the calendar in the main menu?

I found workarounds for most of these, I can modify the calendar addon to allow adding it directly to a language root, and I managed get the first page to forward to a selected language root if stored in the session, but it would be much neater if I could make the modifications as an override or something and not by modifying the existing code.

So my question is mostly that since I'm new to this, have I misunderstood completely how to use the kotti_multilingual addon? Any pointers into the right direction would be appreciated.

Andreas Kaiser

unread,
Jun 22, 2016, 8:54:02 AM6/22/16
to Kotti
On 21 Jun 2016, at 17:56, Anders Nylund wrote:

> The whole kotti/pyramid/sqlalchemy stack is completely new to me, but
> it
> looks like a neat system well worth learning.

It is! Welcome and don't hesitate to ask here or on IRC (#kotti on
Freenode).

> First roadblock is that it doesn't look like it's possible to select a
> language, instead you navigate to a language specific part of the
> tree.
> That works fine I suppose, but then the first page of the site is
> always
> some kind of 'select your language' page. Shouldn't it be possible for
> a
> visitor to select his language just once, and only change it if he
> really
> wants to?

Sure, you could add a view (and make it the default view of your root
object) which tries to get the user's preferred language from the
request (request.accept_language /
http://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.accept_language),
redirect if your site has such a language and otherwise render a "select
language" template.

> Then when you navigate to a language root, the menu will show what's
> one
> level below the language root, but not the language root itself. To
> navigate back to the language root you then need navigate to the first
> page
> and select language again.

In the default templates the site name in the navbar links to the
navigation root, which is "the first page" of the language as soon as
you are "below" a language root (which also is a navigation root).

> Adding a calendar to a document below a language root and translating
> the
> calendar creates a copy on the second language branch, and then events
> can
> be created on both calendars and translated into the other, which
> works
> fine. But the calendar can't be added directly to the language root,
> only
> to a document below it. What if I want the calendar in the main menu?

You need to tell the calendar class, that its instances may be addable
to language roots. Something like this:

Calendar.type_info.addable_to.append('LanguageRoot')

> I found workarounds for most of these, I can modify the calendar addon
> to
> allow adding it directly to a language root, and I managed get the
> first
> page to forward to a selected language root if stored in the session,
> but
> it would be much neater if I could make the modifications as an
> override or
> something and not by modifying the existing code.
>
> So my question is mostly that since I'm new to this, have I
> misunderstood
> completely how to use the kotti_multilingual addon? Any pointers into
> the
> right direction would be appreciated.

No not at all. What you should do is to create a package with the
scaffold Kotti provides and put the customizations mentioned above into
that package. Then use the included ini file to run your application.


HTH,

Andreas

Anders Nylund

unread,
Jun 23, 2016, 1:43:43 AM6/23/16
to Kotti

Thanks, that answers most of my questions (for now at least...) 

> Then when you navigate to a language root, the menu will show what's
> one
> level below the language root, but not the language root itself. To
> navigate back to the language root you then need navigate to the first
> page
> and select language again.

In the default templates the site name in the navbar links to the
navigation root, which is "the first page" of the language as soon as
you are "below" a language root (which also is a navigation root).

Thats exactly how I would like it to work, but it does not seem to be the case in a standard install with kotti_multilingual added.

The navigation looks like this:

Welcome to Kotti (Document)
    Svenska (Language root)
        Svenska 1 (Document)
    English (Language root)
        English 1 (Document)

and on 'English 1' and 'Svenska 1' the site name links to 'Welcome to Kotti'

I suppose the template file is kotti/templates/view/nav.pt and it renders the site name as
      <a class="navbar-brand" href="${request.application_url}/">
        ${api.site_title}
      </a>

I think I can fix that, but if it should work by default there must be something missing in my setup? (kotti 1.2.4, kotti-multilingual 0.2a3)

Then there was also the upcoming events widget in kotti_calendar. When I have two language roots and some translated events the widget shows both the original and the translation as separate events regardless of which language I'm navigating. I suppose I should just make a new view that's aware of the language when collecting events?

Andreas Kaiser

unread,
Jun 23, 2016, 4:17:35 AM6/23/16
to Kotti
On 23 Jun 2016, at 7:43, Anders Nylund wrote:

> Thanks, that answers most of my questions (for now at least...)
>
>>> Then when you navigate to a language root, the menu will show what's
>>> one
>>> level below the language root, but not the language root itself. To
>>> navigate back to the language root you then need navigate to the
>>> first
>>> page
>>> and select language again.
>>
>> In the default templates the site name in the navbar links to the
>> navigation root, which is "the first page" of the language as soon as
>> you are "below" a language root (which also is a navigation root).
>>
>
> Thats exactly how I would like it to work, but it does not seem to be
> the
> case in a standard install with kotti_multilingual added.
>
> The navigation looks like this:
>
> *Welcome to Kotti (Document) Svenska (Language root) Svenska
> 1
> (Document) English (Language root) English 1 (Document)*and
> on
> 'English 1' and 'Svenska 1' the site name links to 'Welcome to Kotti'
>
> I suppose the template file is kotti/templates/view/nav.pt and it
> renders
> the site name as
> <a class="navbar-brand" href="${request.application_url}/">
> ${api.site_title}
> </a>
>
> I think I can fix that, but if it should work by default there must be
> something missing in my setup?

Looking at nav.pt it seems I was wrong. You should override nav.pt and
set nabvar-brand to api.navigation_root.title with
${request.resource_url(api.navigation_root)} as its href. The navbar
items should be correct though.

> (kotti 1.2.4, kotti-multilingual 0.2a3)

I'd strongly suggest to use Kotti 1.3 for new projects. It has some
major improvements, especially w.r.t. performance and file like content.
It's absolutely stable and I use it in several projects without any
issues. The only reason it's still an alpha release is, that migration
of existing projects might not be handled fully automatic in all
situations.

> Then there was also the upcoming events widget in kotti_calendar. When
> I
> have two language roots and some translated events the widget shows
> both
> the original and the translation as separate events regardless of
> which
> language I'm navigating. I suppose I should just make a new view
> that's
> aware of the language when collecting events?

I guess that's right.


HTH,

Andreas

Anders Nylund

unread,
Jun 23, 2016, 5:00:19 AM6/23/16
to Kotti
Thanks, that's all I need to know for now.
Reply all
Reply to author
Forward
0 new messages