diff --git a/system/languages/en.yaml b/system/languages/en.yaml index 5ae01dbde..a1eab6f19 100644 --- a/system/languages/en.yaml +++ b/system/languages/en.yaml @@ -92,3 +92,6 @@ NICETIME: MO_PLURAL: mos YR_PLURAL: yrs DEC_PLURAL: decs +FORM: + VALIDATION_FAIL: Validation failed: + INVALID_INPUT: Invalid input in diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index bf1f5a32f..9bfc32303 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -77,7 +77,8 @@ class Blueprint $this->validateArray($data, $this->nested); } catch (\RuntimeException $e) { $language = self::getGrav()['language']; - throw new \RuntimeException(sprintf('Validation failed: %s', $language->translate($e->getMessage()))); + $message = sprintf($language->translate('FORM.VALIDATION_FAIL', null, true) . ' %s', $e->getMessage()); + throw new \RuntimeException($message); } } diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 653386fe9..c232467ba 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -38,7 +38,7 @@ class Validation $type = (string) isset($field['validate']['type']) ? $field['validate']['type'] : $field['type']; $method = 'type'.strtr($type, '-', '_'); $name = ucfirst(isset($field['label']) ? $field['label'] : $field['name']); - $message = (string) isset($field['validate']['message']) ? $field['validate']['message'] : 'Invalid input in "' . $language->translate($name) . '""'; + $message = (string) isset($field['validate']['message']) ? $field['validate']['message'] : $language->translate('FORM.INVALID_INPUT', null, true) . ' "' . $language->translate($name) . '"'; if (method_exists(__CLASS__, $method)) { $success = self::$method($value, $validate, $field);