You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add to each custom message in rules parameter for set processing type #745
By default, built-in messages that require translation are used. If my app is single language, then I can set one concrete message on my language and set proccessing for this message only. Other message should continue using translation.
When limit is "21", message will be "Превышен лимит в 21 элементов." (Original language for translator is english).
Expected message "Превышен лимит в 21 элемент." (Original language for app is russian). I need to set Error::MESSAGE_FORMAT processing to this message only.
Custom messages you write in Russian, validator build-in messages are translated to Russian from English because you set Russian locale
No. Translator tried translate to russian, but it not found translation and format original message (on russian) with translator original language (english).
Activity
samdark commentedon Aug 28, 2024
Isn't that too much granularity to set that per each message? I think, usually it is turned on/off on whole validator level, not per rule.
vjik commentedon Aug 29, 2024
By default, built-in messages that require translation are used. If my app is single language, then I can set one concrete message on my language and set proccessing for this message only. Other message should continue using translation.
BoShurik commentedon Aug 29, 2024
If you set message in your language but not change message processing nothing changes, isn't it? Translator can't handle it and leaves it as is
vjik commentedon Aug 29, 2024
No. Translator also uses formatter and format message in original language when not found translation.
Real example.
Russian is application language.
Translator configuration is default. Validator configuration:
ValidatorInterface::class => [ 'class' => Validator::class, '__construct()' => [ 'ruleHandlerResolver' => Reference::to(RuleHandlerContainer::class), 'messageFormatter' => Reference::to(IntlMessageFormatter::class), 'messageFormatterLocale' => 'ru-RU', ], ],Rule:
When limit is "21", message will be "Превышен лимит в 21 элементов." (Original language for translator is english).
Expected message "Превышен лимит в 21 элемент." (Original language for app is russian). I need to set
Error::MESSAGE_FORMATprocessing to this message only.BoShurik commentedon Aug 29, 2024
If it's a single language app then you must set this language for translator in the configuration so you get expected message
vjik commentedon Aug 29, 2024
Yes. But for translator language of original messages is English, but custom original messages in app on Russian.
BoShurik commentedon Aug 29, 2024
Custom messages you write in Russian, validator build-in messages are translated to Russian from English because you set Russian locale
vjik commentedon Aug 29, 2024
No. Translator tried translate to russian, but it not found translation and format original message (on russian) with translator original language (english).
BoShurik commentedon Aug 29, 2024
Why it's english if app's locale is russian?
vjik commentedon Aug 29, 2024
Default messages in English (example), so for translator original language is english.
BoShurik commentedon Aug 29, 2024
But there is translation for this message. It wouldn't be translated?