Skip to content

fix(i18n): restore validation messages masked by duplicate top-level lang key [3.x]#144

Merged
ManukMinasyan merged 2 commits into3.xfrom
fix/lang-duplicate-validation-key
Apr 25, 2026
Merged

fix(i18n): restore validation messages masked by duplicate top-level lang key [3.x]#144
ManukMinasyan merged 2 commits into3.xfrom
fix/lang-duplicate-validation-key

Conversation

@ManukMinasyan
Copy link
Copy Markdown
Collaborator

Summary

resources/lang/en/custom-fields.php had 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 using unique custom-field validation):

custom-fields::custom-fields.validation.unique_value

…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 canonical validation block at line 131, then removed the duplicate block. No keys lost.
  • tests/Feature/Translations/LanguageKeysTest.php — added a structural test that scans every resources/lang/<locale>/*.php for 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
  • Manually injected a single-quoted duplicate '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.
  • Removed the injection; test passes.
  • In-browser verification at /shop/orders/3/edit (filament-demo): entering a duplicate email in an Email Unique custom field now displays The value "armen@gmail.com" is already assigned to another record. instead of the raw key.
  • vendor/bin/pint --dirty — pass

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.
Copilot AI review requested due to automatic review settings April 25, 2026 10:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>/*.php files 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.

@ManukMinasyan ManukMinasyan merged commit a91e171 into 3.x Apr 25, 2026
7 checks passed
@ManukMinasyan ManukMinasyan deleted the fix/lang-duplicate-validation-key branch April 25, 2026 21:10
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