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

[Bug]: lang:update flattens validation attributes #210

Open
Gitsimoz opened this issue Jan 22, 2025 · 3 comments
Open

[Bug]: lang:update flattens validation attributes #210

Gitsimoz opened this issue Jan 22, 2025 · 3 comments
Assignees
Labels
bug Something isn't working common Issue related to the "laravel-lang/common" package

Comments

@Gitsimoz
Copy link

Lang Package Name

laravel-lang/lang

Lang Package Version

15.11.7

Laravel Framework Version

11.39

PHP Version

8.3.14

Dependencies

No response

Issue description

I have validation.php file with some attributes (they aren't "request array"):

....
'attributes' => [
    'person' => [
        'first_name' => 'nome',
        'last_name' => 'cognome',
    ],
    ....
]

php artisan lang:update flats these attributes so that __('validation.attributes.person.first_name') will not find them anymore

'attributes' => [
    'person.first_name' => 'nome',
    'person.last_name' => 'cognome',
     ....
]

Steps to reproduce

look at description

@Gitsimoz Gitsimoz added bug Something isn't working common Issue related to the "laravel-lang/common" package labels Jan 22, 2025
@andrey-helldar andrey-helldar changed the title [Bug]: lang:update flattens my validation attributes [Bug]: lang:update flattens validation attributes Jan 22, 2025
@andrey-helldar
Copy link
Member

Does your application use direct access to these attributes?

Usually Form Request does not have such problems and knows how to handle “flat” attributes.

In general, I agree, there is such a problem, but it is not critical. It's just a minor inconvenience when you need to access them manually.

For example:

__('validation.attributes')['person.first_name']

@Gitsimoz
Copy link
Author

Hello,
in our application we use the attributes() method in form request to map complex keys. We do this to avoid defining in the validation file multiple lines with the same translation over and over.

if it's possibile to prevent this flattening from happening with some env keys would be perfect.

@andrey-helldar
Copy link
Member

It's possible, but it will take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working common Issue related to the "laravel-lang/common" package
Projects
None yet
Development

No branches or pull requests

2 participants