Skip to content

Commit

Permalink
Fix validator messages for implicit attributes with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Sep 21, 2016
1 parent 391ba86 commit b7b049a
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 191 deletions.
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

0 comments on commit b7b049a

Please sign in to comment.