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

[9.x] Fixes applying replacements to multi-level localization arrays #42022

Merged
merged 1 commit into from
Apr 18, 2022
Merged

[9.x] Fixes applying replacements to multi-level localization arrays #42022

merged 1 commit into from
Apr 18, 2022

Conversation

dtorras
Copy link
Contributor

@dtorras dtorras commented Apr 17, 2022

This pull request fixes the localization parameters replacement when retrieving a multi-level localization array.

Back on 5.7 (#27254) this was fixed for single-level arrays, but it fails if you are retrieving something with more levels because makeReplacements function expects a string, not an array.

For example, currently this will fail:

trans('foo', ['appName' => 'Laravel'])

Translation file lang/en/foo.php:

return [
    'bar' => 'tree :appName',
    'qux' => [
        'baz' => 'localization :appName',
        'thud' => [
            'vapor' => 'level :appName',
        ],
    ],
];

This solution walks all the values recursively in the array case instead of just looping on the first-level array.

@GrahamCampbell GrahamCampbell changed the title Fixes applying replacements to multi-level localization arrays. [9.x] Fixes applying replacements to multi-level localization arrays Apr 17, 2022
@taylorotwell taylorotwell merged commit e209f38 into laravel:9.x Apr 18, 2022
@dtorras dtorras deleted the recursive_replacements branch April 19, 2022 09:21
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

Successfully merging this pull request may close these issues.

2 participants