0. Screenshot
1. Requirement
- Symfony >= 3.4
- Your Doctrine objects configured with an i18n strategy of your choice
Strategies documentations :
- KnpDoctrineExtension An indexBy strategy PHP5.4+ Recommended
- A2lixI18nDoctrineBundle An indexBy strategy
- PrezentDoctrineTranslatableBundle An indexBy strategy PHP5.3
2. Installation
Use composer
After the successful installation, add/check the bundle registration
3. Configuration
There is no minimal configuration. Full list of optional parameters:
-
[1] Custom locale provider service id. Default one relies on [1-*] values:
- [1-a] List of translations locales to display
- [1-b] Default locale
- [1-c] List of required translations locales
- [2] The default template is Twitter Bootstrap compatible. You can redefine your own here
4. Usage
In a classic formType
Advanced examples
- [1] Optional. If set, override the default value from config.yml
- [2] Optional. If set, override the default value from config.yml
- [3] Optional. If set, override the auto configuration of fields
- [3.a] Optional. - For a field, applied to all locales
- [3.b] Optional. - For a specific locale of a field
- [4] Optional. Common options of symfony forms (max_length, required, trim, read_only, constraints, ...), which was added 'field_type' and 'display'
- [5] Optional. Set the labels for the translation tabs. Default to the name of the locale. Translation keys can be used here.
5. Additional
TranslationsFormsType
A different approach for entities which don't share fields untranslated. No strategy used here, only a locale field in your entity.
- [1] Optional. If set, override the default value from config.yml
- [2] Mandatory. A real form type that you have to do
- [2bis] Optional. - An array of options that you can set to your form
TranslatedEntityType
Modified version of the native 'entity' symfony form type to translate the label in the current locale by reading translations
- [1] Path of the translatable class
- [2] Property/Method of the translatable class that will be display
- [3] Common options of the 'entity' Symfony form type (multiple, ...)
Example
See Demo Bundle for more examples.