Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localization question #225

Open
romaninsh opened this issue Apr 23, 2017 · 2 comments
Open

localization question #225

romaninsh opened this issue Apr 23, 2017 · 2 comments

Comments

@romaninsh
Copy link

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

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

@rquadling
Copy link
Contributor

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.

@romaninsh
Copy link
Author

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?

rquadling pushed a commit that referenced this issue Jan 25, 2018
…essage for an assertion if one is not supplied (Thanks to [Romans Malinovskis](#225))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants