-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Custom attribute name translations don't work #155
Comments
Use interpolated dot string to directly fetch attribute translations instead of retrieving ALL custom attribute translations, then fetching from them via Arr::get This improves support for alternate translator implementations. Fixes https://github.com/flarum/core/issues/2572
Use interpolated dot string to directly fetch attribute translations instead of retrieving ALL custom attribute translations, then fetching from them via Arr::get This improves support for alternate translator implementations. Fixes https://github.com/flarum/core/issues/2572
When this is done, we should revisit https://github.com/flarum/core/pull/2408/files#r560572646 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. |
Bug Report
Current Behavior
Discovered while working on flarum/framework#2408 (comment).
When a validation error occurs, attribute names aren't translated, even those included in
validation.yml
; instead, a snake-case-without-spaces version in English is shown.This has been around for a while: https://discuss.flarum.org/d/18424-values-from-attributes-not-translated
Steps to Reproduce
Expected Behavior
Attribute names should be translated as per
validation.yml
Possible Solution
I've managed to track this down to https://github.com/illuminate/validation/blob/v8.24.0/Concerns/FormatsMessages.php (version is arbitrary, it's been that way since recent history). Looks like Laravel's translator tries to retrieve ALL custom attribute names as an array, then get the proper element via
Arr::get
. This is incompatible with our use of Symfony's translator, which will only return individual translated items, not translation sub-namespaces.I don't think this is something we can change in Flarum, so a PR to Laravel feels most appropriate. As per https://laravel.com/docs/master/releases, v6.x should be eligible for bugfixes for quite a while.
EDIT: Laravel's implementation is significantly different enough that a common mechanism won't work. I'm not sure if there's a trivial fix for this, and I don't think we should maintain a custom subclass of
Validator
orValidation/Factory
.The text was updated successfully, but these errors were encountered: