mirror of
https://github.com/Respect/Validation.git
synced 2024-06-01 05:12:50 +02:00
Move "Message translation" documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
7be7f0f58c
commit
5c0bd3a5da
|
@ -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
|
||||
|
|
17
docs/message-translation.md
Normal file
17
docs/message-translation.md
Normal 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.
|
Loading…
Reference in a new issue