PHPackages                             elao/form-translation-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. elao/form-translation-bundle

ActiveSymfony-bundle[Localization &amp; i18n](/categories/localization)

elao/form-translation-bundle
============================

Generate translation key for forms

v5.0.0(1mo ago)44239.7k↓43.5%12[1 issues](https://github.com/Elao/ElaoFormTranslationBundle/issues)[1 PRs](https://github.com/Elao/ElaoFormTranslationBundle/pulls)1MITPHPPHP ^8.2CI passing

Since Jan 28Pushed 1mo ago16 watchersCompare

[ Source](https://github.com/Elao/ElaoFormTranslationBundle)[ Packagist](https://packagist.org/packages/elao/form-translation-bundle)[ Docs](https://github.com/Elao/ElaoFormTranslationBundle)[ RSS](/packages/elao-form-translation-bundle/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (20)Versions (19)Used By (1)

ElaoFormTranslationBundle
=========================

[](#elaoformtranslationbundle)

[![CI](https://github.com/Elao/ElaoFormTranslationBundle/actions/workflows/ci.yaml/badge.svg)](https://github.com/Elao/ElaoFormTranslationBundle/actions/workflows/ci.yaml)

Description:
------------

[](#description)

This bundle provides a nice way of generating translation keys for form fields in a "logic" way. It is used mainly to generate automatic labels on fields but can be use to build any key.

**For example, in a form `RegisterType` named "register" the key for its field "name" would be `form.register.children.name.label`.**

Another more advanced example would be a field "emails" which is a `collection` of `text` inputs, it'll generate:

- `form.register.children.emails.label`
- `form.register.children.emails.label_add`
- `form.register.children.emails.label_delete`
- `form.register.children.emails.children.prototype.label`

Or in `yml`:

```
form:
    register:
        children:
            emails:
                label:          # add your trans for the fieldset ex: Email
                label_add:      # add your trans for add button ex: Add an email
                label_delete:   # add your trans for remove button ex: Remove an email
                children:
                    prototype:
                        label:  # add your trans for the label of one email field ex: Email address
```

*Note: The keys will only be generated at runtime and won't be dumped when you use `translation:update` yet (we're working on it).*

Installation:
-------------

[](#installation)

This bundle supports maintained Symfony versions only.

Add ElaoFormTranslationBundle to your composer.json:

```
{
    "require": {
        "elao/form-translation-bundle": "4.*"
    }
}
```

Now download the bundle by running the command:

```
$ php composer.phar update elao/form-translation-bundle
```

```

How to use it:
--------------

In order to generate translation keys automatically, you have 2 options:

#### Per field generation:

If you set the the "label" option of a form field to __true__, a key will be generated and set as the field label.
__Otherwise we won't generate your labels !__

``` php
