assert icon indicating copy to clipboard operation
assert copied to clipboard

localization question

Open romaninsh opened this issue 8 years ago • 2 comments

Just curious, what is the best way to localize this method:

https://github.com/beberlei/assert/blob/master/lib/Assert/Assertion.php#L2558

romaninsh avatar Apr 23 '17 10:04 romaninsh

You can override the method in your own subclass, or you can provide a callback with each assertion.

But it would probably be better to provide your own Exception class that will generate an appropriate message based upon the exception code.

rquadling avatar Apr 23 '17 21:04 rquadling

This wouldn't work with default messages though:

https://github.com/beberlei/assert/blob/master/lib/Assert/Assertion.php#L2543

$message = \sprintf(static::generateMessage($message) ?: 'Value "%s" expected to be a defined constant.', $constant);

while something like this would work:

$message = \sprintf(static::generateMessage($message ?: 'Value "%s" expected to be a defined constant.'), $constant);

any ideas?

romaninsh avatar May 02 '17 09:05 romaninsh