Skip to content

Commit

Permalink
README.md - info about parameters in messages (#22)
Browse files Browse the repository at this point in the history
* README.md - info about parameters in messages

* readme.md - add link to parameters in messages
  • Loading branch information
Gappa authored Mar 4, 2020
1 parent 6ed756b commit cb55946
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Model](#model)
- [Latte](#latte)
- [Neon](#neon)
- [Parameters in messages](#parameters-in-messages)
- [Loaders](#loaders)
- [File loaders](#file-loaders)
- [Database loaders](#database-loaders)
Expand Down Expand Up @@ -169,6 +170,30 @@ prefix:
for: "message" # messages.prefix.for
```

### Parameters in messages

Sometimes it is convenient to include a dynamic parameter in the translation - as seen in the Latte examples above.

Neon:

``` yaml
user.name.taken: "Sorry, the username %name% is already taken, please try a different one."
```

Latte:

``` smarty
{_user.name.taken, [name => "Ales"]}
```

Presenter/Model:

``` php
$this->translator->translate('user.name.taken', [name => 'Ales']);
```

**Note**: When passing parameters to the translator, the parameter names must not be enclosed in `%` characters. This is done by `Contributte/Translation` automatically.

## Loaders

By default the extension will look for `.neon` files.
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Symfony/Translation integration for [Nette Framework](https://nette.org).
- [Model](.docs/README.md#model)
- [Latte](.docs/README.md#latte)
- [Neon](.docs/README.md#neon)
- [Parameters in messages](.docs/README.md#parameters-in-messages)
- [Loaders](.docs/README.md#loaders)
- [File loaders](.docs/README.md#file-loaders)
- [Database loaders](.docs/README.md#database-loaders)
Expand Down

0 comments on commit cb55946

Please sign in to comment.