fix(i18n): restore validation messages masked by duplicate top-level lang key [3.x]#144
Merged
ManukMinasyan merged 2 commits into3.xfrom Apr 25, 2026
Merged
Conversation
PHP silently keeps only the last duplicate array key, which can mask entire blocks of translations. The previous duplicate `'validation'` key wiped out 200+ entries (including `unique_value`) and existing key-existence tests didn't catch it because none of the listed keys happened to live in the masked block. Adds a structural assertion across every `resources/lang/<locale>/*.php` file so future duplicates fail fast.
There was a problem hiding this comment.
Pull request overview
This PR fixes a Laravel translation regression caused by a duplicate top-level array key in resources/lang/en/custom-fields.php, where PHP silently kept only the last 'validation' block and masked the earlier (canonical) one—resulting in raw translation keys being shown to users.
Changes:
- Merged the small duplicate
'validation'block into the canonical'validation'section and removed the duplicate definition. - Added a Pest test to detect duplicate top-level keys across all
resources/lang/<locale>/*.phpfiles to prevent similar masking issues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
resources/lang/en/custom-fields.php |
Removes the duplicate top-level validation key by merging entries into the canonical block, restoring masked translations like unique_value. |
tests/Feature/Translations/LanguageKeysTest.php |
Adds a structural safeguard test that scans language files for duplicate top-level keys that PHP would otherwise silently overwrite. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resources/lang/en/custom-fields.phphad two top-level'validation' => [...]blocks at lines 131 and 544. PHP silently keeps only the last occurrence of duplicate array keys, so the 11-key block at the bottom wiped out the 200+ key block above it — including'unique_value'(line 355).User-visible symptom on
Edit Order(and any model usinguniquecustom-field validation):…was rendered verbatim instead of the translated message, because
__()couldn't resolve the key.Changes
resources/lang/en/custom-fields.php— merged the 11 capability labels (min_length,max_length,min_value,max_value,min_selections,max_selections,max_file_size_kb,accepted_file_types,accepted_file_types_placeholder,decimal_places,decimal_places_placeholder) into the canonicalvalidationblock at line 131, then removed the duplicate block. No keys lost.tests/Feature/Translations/LanguageKeysTest.php— added a structural test that scans everyresources/lang/<locale>/*.phpfor duplicate top-level keys and asserts none exist. Existing key-existence tests didn't catch this because none of the listed keys happened to live in the masked block.Test plan
vendor/bin/pest tests/Feature/Translations/— 131 passed'validation'block; new test fails with:Duplicate top-level key(s) in en/custom-fields.php: validation. PHP keeps only the last definition, masking earlier values./shop/orders/3/edit(filament-demo): entering a duplicate email in anEmail Uniquecustom field now displaysThe value "armen@gmail.com" is already assigned to another record.instead of the raw key.vendor/bin/pint --dirty— pass