From 3505ef046d6e9340b3ee258f452e7e5ddbeb212b Mon Sep 17 00:00:00 2001 From: Paul Bovis Date: Tue, 17 Nov 2015 11:50:47 -0700 Subject: [PATCH 1/2] Added a translation for "Validation failed:" text The English term "Validation failed:" was hard coded on line 83. Instead, I created a translation and placed this at /system/languages/en.yaml. It will need to be translated into other languages by others. --- system/src/Grav/Common/Data/Blueprint.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index bf1f5a32f..7aa51440e 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -72,12 +72,15 @@ class Blueprint { // Initialize data $this->fields(); + + // Get language class + $language = self::getGrav()['language']; try { $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); } } From 3f94a6fda97b2589f3cd3be3d6c8240f329a8079 Mon Sep 17 00:00:00 2001 From: Paul Bovis Date: Tue, 17 Nov 2015 14:25:51 -0700 Subject: [PATCH 2/2] moved $language variable inside catch statement As requested --- system/src/Grav/Common/Data/Blueprint.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index 7aa51440e..9bfc32303 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -72,13 +72,11 @@ class Blueprint { // Initialize data $this->fields(); - - // Get language class - $language = self::getGrav()['language']; try { $this->validateArray($data, $this->nested); } catch (\RuntimeException $e) { + $language = self::getGrav()['language']; $message = sprintf($language->translate('FORM.VALIDATION_FAIL', null, true) . ' %s', $e->getMessage()); throw new \RuntimeException($message); }