Skip to content

Support for array translations #324

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

N1ebieski
Copy link
Contributor

@N1ebieski N1ebieski commented Mar 9, 2025

Fixes #300

This PR adds support for array translations for example:

resources/lang/en/validation.php:

'attributes' => [
    'question' => [
        'email' => 'email address',
    ],
]

Currently, the code:

__('validation.attributes.question')

shows:

Translation [validation.attributes.question] not found.Laravel Extension(translation)

but this key exists, it's only an array with nested elements.

This PR adds support for such keys for hovering and linking to the first element in the array. However, the value is not shown in the hover, because it's an array.

This code needs futher refactoring and testing.

@tharlei
Copy link

tharlei commented Mar 12, 2025

Nice PR! 🚀

It is also interesting to apply it to the locale that I passed to the __() or trans() method

Example:

__('validation.attributes.question', locale: 'pt-BR')

Check the pt-BR folder this transcription

@N1ebieski
Copy link
Contributor Author

@tharlei #330

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.

[Bug]: Fail to find nested translation
2 participants