cedriclombardot/AdmingeneratorGeneratorBundle — pull request #209 by loostro (2012-07-28 13:36:14+00:00)
Title: Translations with arguments

# These changes allow translations with arguments.

The most important about this change is, that it does not need changeing current templates.

If you have template code:

> {{ echo_trans(field.label, 'Admin') }}

and field label is **Custom edit label** then echo_trans will work just like normal (becouse "Custom edit label" does not match regular expression).

### Basic example:

```yaml
params:
i18n_catalog: AcmeDemoBundle
builders:
edit:
params:
title: "'acme.box.edit.title'|{'%id%': Box.id }"
```

Will generate code:

> {% trans with {'%id%': Box.id } from "AcmeDemoBundle" %}acme.box.edit.title{% endtrans %}

AcmeDemoBundle.en.yml:

```yaml
acme.box.edit.title: "You are editing box with ID: %id%!"
```

Which will be translated to (for Box.id = 5):

> You are editing box with ID: 5

### Multiple arguments example:

```yaml
params:
i18n_catalog: AcmeDemoBundle
builders:
edit:
params:
title: "'acme.box.edit.title'|{'%id%': Box.id, '%color%': Box.color, '%test%': 'MyTestString' }"
```

Will generate code:

> {% trans with {'%id%': Box.id, '%color%': Box.color, '%test%': 'MyTestString' } from "AcmeDemoBundle" %}acme.box.edit.title{% endtrans %}

AcmeDemoBundle.en.yml:

```yaml
acme.box.edit.title: "You are editing box with: ID = %id%, COLOR = %color% and TEST = %test%!"
```

Which will be translated to (for Box.id = 5, Box.color = red):

> You are editing box with: ID = 5, COLOR = red and TEST = MyTestString!