From 6c6bd16bfaad2c19dacf82eadb9d14be4ec3291d Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Fri, 23 May 2025 17:22:45 +0200 Subject: [PATCH] feat(tags): allow to translate tags validation attributes --- extensions/tags/src/Listener/SaveTagsToDatabase.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/tags/src/Listener/SaveTagsToDatabase.php b/extensions/tags/src/Listener/SaveTagsToDatabase.php index c6d04c4c52..c648a3de6a 100755 --- a/extensions/tags/src/Listener/SaveTagsToDatabase.php +++ b/extensions/tags/src/Listener/SaveTagsToDatabase.php @@ -134,11 +134,16 @@ protected function validateTagCount($type, $count) $max = $this->settings->get('flarum-tags.max_'.$type.'_tags'); $key = 'tag_count_'.$type; + /** @var \Illuminate\Validation\Validator $validator */ $validator = $this->validator->make( [$key => $count], [$key => ['numeric', $min === $max ? "size:$min" : "between:$min,$max"]] ); + $validator->setAttributeNames([ + $key => $this->translator->trans("flarum-tags.validation.attributes.$key"), + ]); + if ($validator->fails()) { throw new ValidationException([], ['tags' => $validator->getMessageBag()->first($key)]); }