Multilangual sites with Kotti
Multilingual Sites with Kotti.
Kotti’s data model includes a language attribute on the Content class, from which all content types inherit. However, this attribute is neither exposed by Kotti’s UI, nor used in any other way. kotti_multilingual provides a generic approach to build multilingual sites.
kotti_multilingual is still in an early stage of development. It is neither feature complete nor can be considered API stable. Things will change!
The package contains a single content type LanguageRoot which is supposed to be the container of all content in a specific language. All content that is created in (or moved into) such a subtree will be automatically tagged with the language of the root. This is done by subscribing to Kotti’s ObjectInsert and ObjectUpdate events.
You can place LanguageRoot instances wherever you want in your content tree, but it is considered best practice to have a tree structure like this:
- / Document language neutral - /en LanguageRoot English - /de LanguageRoot German - /nl LanguageRoot Dutch - /images Document language neutral
To activate the kotti_multilingual add-on in your Kotti site, you need to add an entry to the kotti.configurators setting in your Paste Deploy config. If you don’t have a kotti.configurators option, add one. The added entry should look like this:
kotti.configurators = kotti_multilingual.kotti_configure
You can register an optional kotti_multilingual.blacklist with the list of the type names not handled by kotti_multilingual.
The test setup requires additional steps:
$ virtualenv --no-site-packages . $ source bin/activate $ pip install -r requirements.txt $ python setup.py develop $ python setup.py dev
How to launch tests:
Maintain translation links between content items, with translation source and targets.
Add a translation dropdown UI for adding a translation of an item.
Added widget.i10n_widget_factory deferred widget. Turns field into readonly mode if the context is a translation.
This deferred widget is also compatible with add forms, you should bind an addform property to True and the widget will be rendered as usual in edit mode. You can do that adding a get_bind_data method on your add form.
Added a kotti_multilingual.blacklist setting with a list of type names not translatable
Changed policy for translate action. Now the translated document is automatically filled with the parent translation (enhanced usability since we don’t have the screen splitted in two parts like LinguaPlone). This is possible thanks to a change in sqla.py since we don’t set language independent attributes on translated documents
Fixed translation of objects with not nullable fields
Added support for sqlalchemy’s association_proxy
Fixed intermittent problem with get_source (integrity error)