diff --git a/src/Fieldtypes/Assets/DimensionsRule.php b/src/Fieldtypes/Assets/DimensionsRule.php index 8f980a2da0..11c682f7f0 100644 --- a/src/Fieldtypes/Assets/DimensionsRule.php +++ b/src/Fieldtypes/Assets/DimensionsRule.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Validation\Rule; use Statamic\Facades\Asset; +use Statamic\Statamic; use Symfony\Component\HttpFoundation\File\UploadedFile; class DimensionsRule implements Rule @@ -63,7 +64,7 @@ public function passes($attribute, $value) */ public function message() { - return __('statamic::validation.dimensions'); + return __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.dimensions'); } /** diff --git a/src/Fieldtypes/Assets/ImageRule.php b/src/Fieldtypes/Assets/ImageRule.php index ba3f6fb6e3..b32985ec0e 100644 --- a/src/Fieldtypes/Assets/ImageRule.php +++ b/src/Fieldtypes/Assets/ImageRule.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Validation\Rule; use Statamic\Facades\Asset; +use Statamic\Statamic; use Symfony\Component\HttpFoundation\File\UploadedFile; class ImageRule implements Rule @@ -46,6 +47,6 @@ public function passes($attribute, $value) */ public function message() { - return __('statamic::validation.image'); + return __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.image'); } } diff --git a/src/Fieldtypes/Assets/MaxRule.php b/src/Fieldtypes/Assets/MaxRule.php index c9015a1441..8a5f04e86f 100644 --- a/src/Fieldtypes/Assets/MaxRule.php +++ b/src/Fieldtypes/Assets/MaxRule.php @@ -2,6 +2,8 @@ namespace Statamic\Fieldtypes\Assets; +use Statamic\Statamic; + class MaxRule extends SizeBasedRule { /** @@ -22,6 +24,6 @@ public function sizePasses($size) */ public function message() { - return str_replace(':max', $this->parameters[0], __('statamic::validation.max.file')); + return str_replace(':max', $this->parameters[0], __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.max.file')); } } diff --git a/src/Fieldtypes/Assets/MimesRule.php b/src/Fieldtypes/Assets/MimesRule.php index 68206a4af2..485ac393cf 100644 --- a/src/Fieldtypes/Assets/MimesRule.php +++ b/src/Fieldtypes/Assets/MimesRule.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Validation\Rule; use Statamic\Facades\Asset; +use Statamic\Statamic; use Symfony\Component\HttpFoundation\File\UploadedFile; class MimesRule implements Rule @@ -48,6 +49,6 @@ public function passes($attribute, $value) */ public function message() { - return str_replace(':values', implode(', ', $this->parameters), __('statamic::validation.mimes')); + return str_replace(':values', implode(', ', $this->parameters), __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.mimes')); } } diff --git a/src/Fieldtypes/Assets/MimetypesRule.php b/src/Fieldtypes/Assets/MimetypesRule.php index fd4a971ff9..ad1c82acaa 100644 --- a/src/Fieldtypes/Assets/MimetypesRule.php +++ b/src/Fieldtypes/Assets/MimetypesRule.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\Validation\Rule; use Statamic\Facades\Asset; +use Statamic\Statamic; use Symfony\Component\HttpFoundation\File\UploadedFile; class MimetypesRule implements Rule @@ -43,6 +44,6 @@ public function passes($attribute, $value) */ public function message() { - return str_replace(':values', implode(', ', $this->parameters), __('statamic::validation.mimetypes')); + return str_replace(':values', implode(', ', $this->parameters), __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.mimetypes')); } } diff --git a/src/Fieldtypes/Assets/MinRule.php b/src/Fieldtypes/Assets/MinRule.php index fe35ec8a3b..b37bfaa587 100644 --- a/src/Fieldtypes/Assets/MinRule.php +++ b/src/Fieldtypes/Assets/MinRule.php @@ -2,6 +2,8 @@ namespace Statamic\Fieldtypes\Assets; +use Statamic\Statamic; + class MinRule extends SizeBasedRule { /** @@ -22,6 +24,6 @@ public function sizePasses($size) */ public function message() { - return str_replace(':min', $this->parameters[0], __('statamic::validation.min.file')); + return str_replace(':min', $this->parameters[0], __((Statamic::isCpRoute() ? 'statamic::' : '').'validation.min.file')); } } diff --git a/tests/Fieldtypes/AssetsTest.php b/tests/Fieldtypes/AssetsTest.php index 636e63da38..1abd1d0548 100644 --- a/tests/Fieldtypes/AssetsTest.php +++ b/tests/Fieldtypes/AssetsTest.php @@ -106,6 +106,8 @@ public function it_shallow_augments_to_a_single_asset_when_max_files_is_one() /** @test */ public function it_replaces_dimensions_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['dimensions:width=180,height=180']])->fieldRules(); $this->assertIsArray($replaced); @@ -117,6 +119,8 @@ public function it_replaces_dimensions_rule() /** @test */ public function it_replaces_image_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['image']])->fieldRules(); $this->assertIsArray($replaced); @@ -128,6 +132,8 @@ public function it_replaces_image_rule() /** @test */ public function it_replaces_mimes_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['mimes:jpg,png']])->fieldRules(); $this->assertIsArray($replaced); @@ -139,6 +145,8 @@ public function it_replaces_mimes_rule() /** @test */ public function it_replaces_mimestypes_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['mimetypes:image/jpg,image/png']])->fieldRules(); $this->assertIsArray($replaced); @@ -150,6 +158,8 @@ public function it_replaces_mimestypes_rule() /** @test */ public function it_replaces_min_filesize_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['min_filesize:100']])->fieldRules(); $this->assertIsArray($replaced); @@ -161,6 +171,8 @@ public function it_replaces_min_filesize_rule() /** @test */ public function it_replaces_max_filesize_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['max_filesize:100']])->fieldRules(); $this->assertIsArray($replaced); @@ -172,6 +184,8 @@ public function it_replaces_max_filesize_rule() /** @test */ public function it_doesnt_replace_non_image_related_rule() { + config()->set('statamic.cp.route', '/'); + $replaced = $this->fieldtype(['validate' => ['file']])->fieldRules(); $this->assertIsArray($replaced);