0. Screenshot
1. Requirement
- Symfony >= v2.3 but Symfony < 3.x
- Your Doctrine objects configured with an i18n strategy
Some i18n strategies that I can advise you, order by preference :
- A2lixI18nDoctrineBundle An indexBy strategy
- KnpDoctrineExtension An indexBy strategy PHP5.4
- PrezentDoctrineTranslatableBundle An indexBy strategy PHP5.3
- GedmoDoctrineExtension (with persistDefaultLocaleTranslation enabled)
- GedmoDoctrineExtension (with its default configuration)
2. Installation
Use composer
After the successful installation, add in your AppKernel.php file
3. Configuration
There is no minimal configuration. Full list:
- [1] Locales of translations
- [2] Default to true
- [3] Default to doctrine
- [4] The default template is Twitter Bootstrap compatible. You can redefine your own template
4. Usage
For indexBy strategies
In a classic formType
Gedmo strategy specificity
You have to use 'a2lix_translations_gedmo' instead of 'a2lix_translations'
If you use GedmoDoctrineExtension (with its default configuration) with the choice to include the default locale with translations locales, you need to specify the 'translatable_class' option.
Advanced examples
- [1] Optionnal. If set, override the default value from config.yml
- [2] Optionnal. If set, override the default value from config.yml
- [3] Optionnal. If set, override the auto configuration of fields
- [3.a] Optionnal. - For a field, applied to all locales
- [3.b] Optionnal. - For a specific locale of a field
- [4] Optionnal. Common options of symfony forms (max_length, required, trim, read_only, constraints, ...), which was added 'field_type' and 'display'
5. Additional
Quick forms
- [1] Optionnal. If set, override the default value from config.yml
- [2] Mandatory. A real form type that you have to do
- [2bis] Optionnal. - An array of options that you can set to your form
Assets
If you already use Twitter Bootstrap, you only need to enable the Tab functionality and use a2lix_translation_bootstrap.js.
Otherwise, you will still need jquery, and you use a2lix_translation_default.js and a2lix_translation_default.css.
6. Advanced
If you use PHP5.4, you can use some traits provided in Util repository
If you use GedmoDoctrineExtension (with its default configuration) and a multilingual backoffice, you need, during edition of your forms,
to fix the current locale to the default locale.
I provide an annotation 'GedmoTranslation' for help you.