Skip to main content

Multi language fields for Plone

Project description

Introduction

This package aims to provide a simple way to make some fields on a dexterity content type available in more than one language (“multilanguage”). It tries to do what raptus.multilanguagefields does for Archetypes content types.

Assumptions

  • It should be possible for a site to add a new supported language without having to migrate content. (A modification in the code for your customer-specific package would be ok.)

Usage

Multilanguage text line:

from collective.multilanguagefields.fields import TextLine as MLTextLine
from plone.supermodel import model

class IMyType(model.Schema):

    some_text = MLTextLine(
        title=_(u"Fieldname"),
        required=True,
    )

Features

Compatibility

Plone 4.3 and upwards.

Making Title field multilanguage

You cant use the default plone.app.content.interfaces.INameFromTitle behavior. Instead, use collective.multilanguagefields.interfaces.INameFromMultiLanguageTitle

In addition, your content type needs to implement its own Title() method which takes into account that the title attribute contains a dictionary. The ml_value method from utils.py might be helpful.

Using multilanguage fields in templates

You can do this as follows:

<span tal:content="context/ml_value/my_field" />

You can also specify a default value:

<span tal:define="ml_value context/ml_value"
      tal:content="python: ml_value('my_field', 'no translation found')" />

Changelog

0.3 (2015-01-05)

  • Nothing changed yet.

0.2 (2015-01-05)

  • Nothing changed yet.

0.1.1 (2015-01-02)

  • Nothing changed yet.

0.1 (2015-01-02)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.multilanguagefields-0.3.zip (25.1 kB view details)

Uploaded Source

File details

Details for the file collective.multilanguagefields-0.3.zip.

File metadata

File hashes

Hashes for collective.multilanguagefields-0.3.zip
Algorithm Hash digest
SHA256 77ae6d310ee18604ccc3323a54d38daf781f467930c9b543be49b2d7d6277f40
MD5 f4ae5dd590bef4eb6c1e6e8f9042ead5
BLAKE2b-256 50eab14c18dfeba97bf1736a753f970305291148ea06c4c8253c1c1d7728f848

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page