Translatable type

This translatable type makes reference to Softspring\CmsBundle\Form\Type\TranslatableType form type.

This form type provides multiple language values for any field and type.

It uses the de %kernel.enabled_locales% and %kernel.default_locale% values to configure languages, as default.

Translate texts

The most common use of this type is to translate texts.

The "translatedText" type is deprecated. You should use this method.

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "text"

The values are stored as a json object with locale as key:

{
    "description": {
        "en": "Product",
        "es": "Producto",
        "de": "Produkt"
    }
}

Render values

The way to render translated values is using it as an array, accessing it throw the locale:

{{ description|sfs_cms_trans }}

Also is posible to render it using description[app.request.locale]|default but it's not recommended because it
does not take into account the default locale.

Preview values

Preview values works similiar as contained type does, but accesing it throw the locale:

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "text"
                    type_options:
                        attr:
                            data-edit-content-input: 'description'
{% for locale,localeField in form.description.vars.localeFields %}
    <p data-edit-content-target="description.{{ locale }}" data-lang="{{ locale }}" contenteditable="true">{{ localeField.vars.data|default('description')|raw }}</p>
{% endfor %}

Translate medias

This documentation page is not yet written

Options

type

type: string required

Form type for children elements. You can use any type in the way that CMS modules use them:

Using short names

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "text"

Keep in mind that it translates this type names as follows (this preference order):

  1. App\Form\Type\Type
  2. Softspring\CmsBundle\Form\Type\Type
  3. Symfony\Component\Form\Extension\Core\Type\Type

Using fully qualified domain names

You can specify a fully qualified domain name to use an specific form type,

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "Symfony\Component\Form\Extension\Core\Type\ColorType"

or other namespace type:

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "Vendor\FeatureBundle\Type\ExampleType"

type_options

type: array default: []

Configures the selected type options:

module:
    module_options:
        form_fields:
            description:
                type: "translatable"
                type_options:
                    type: "choice"
                    type_options:
                        multiple: true
                        expanded: true
                        choices: 
                            example1: 1
                            example2: 2

languages

type: array default: %kernel.enabled_locales%

default_language

type: string default: %kernel.default_locale%

children_attr

type: array default: []