Move "Message translation" documentation

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-05-22 20:52:52 +02:00
parent 7be7f0f58c
commit 5c0bd3a5da
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 17 additions and 18 deletions

View file

@ -228,24 +228,6 @@ Array
Note that `getMessage()` will only return a message when the specific validation
in the chain fails.
## Message localization
You're also able to translate your message to another language with Validation.
The only thing one must do is to define the param `translator` as a callable that
will handle the translation overwriting the default factory:
```php
Factory::setDefaultInstance(
(new Factory())->withTranslator('gettext')
);
```
The example above uses `gettext()` but you can use any other callable value, like
`[$translator, 'trans']` or `you_custom_function()`.
After that, if you call `getMessage()`, `getMessages()`, or `getFullMessage()`,
the message will be translated.
## Message placeholder conversion
Message in Validation usually have placeholders that are in between "{{" and

View file

@ -0,0 +1,17 @@
# Message translation
You're also able to translate your message to another language with Validation.
The only thing one must do is to define the param `translator` as a callable that
will handle the translation overwriting the default factory:
```php
Factory::setDefaultInstance(
(new Factory())->withTranslator('gettext')
);
```
The example above uses `gettext()` but you can use any other callable value, like
`[$translator, 'trans']` or `you_custom_function()`.
After that, if you call `getMessage()`, `getMessages()`, or `getFullMessage()`,
the message will be translated.