Skip to content

[5.3] Fix validator messages for implicit attributes with errors #15538

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

Merged
merged 1 commit into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Illuminate/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ public function get($key, array $replace = [], $locale = null, $fallback = true)
return $line;
}

/**
* Add translation lines to the given locale.
*
* @param array $lines
* @param string $locale
* @param string $namespace
* @return void
*/
public function addLines(array $lines, $locale, $namespace = '*')
{
foreach ($lines as $key => $value) {
list($group, $item) = explode('.', $key, 2);

Arr::set($this->loaded, "$namespace.$group.$locale.$item", $value);
}
}

/**
* Retrieve a language line out the loaded array.
*
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2242,12 +2242,10 @@ protected function getAttribute($attribute)
return $this->customAttributes[$expectedAttributeName];
}

$key = "validation.attributes.{$expectedAttributeName}";

// We allow for the developer to specify language lines for each of the
// attributes allowing for more displayable counterparts of each of
// the attributes. This provides the ability for simple formats.
if (($line = $this->translator->trans($key)) !== $key) {
if ($line = Arr::get($this->translator->get('validation.attributes'), $expectedAttributeName)) {
return $line;
}
}
Expand Down
Loading