$description = trans("validation.{$rule}");
// For rules that can apply to multiple types (eg 'max' rule), Laravel returns an array of possible messages
// 'numeric' => 'The :attribute must not be greater than :max'
// 'file' => 'The :attribute must have a size less than :max kilobytes'
if (is_array($description)) {
$description = $description[$baseType];
}
It expects trans to return an array for the max rule. However, our application uses a different translation engine (specifically joedixon/laravel-translation with translations in the database) that does not support returning arrays.
In any case, I have fixed the issue by changing it to:
I have no idea how widespread this issue is, and I haven't found any official docs on creating translation engines. Maybe it's the engine's fault. Unfortunately, it was a bit of a pain to fix, because I had to extend 5 strategies that use the ParsesValidationRules trait and add a test that checks the original getDescription for code changes. Would you consider adding this change?
Scribe version
4.33.0
PHP version
8.1
Framework
Laravel
Framework version
10.*
Scribe config
What happened?
This code is in ParsesValidationRules:
It expects trans to return an array for the max rule. However, our application uses a different translation engine (specifically
joedixon/laravel-translation
with translations in the database) that does not support returning arrays.In any case, I have fixed the issue by changing it to:
I have no idea how widespread this issue is, and I haven't found any official docs on creating translation engines. Maybe it's the engine's fault. Unfortunately, it was a bit of a pain to fix, because I had to extend 5 strategies that use the ParsesValidationRules trait and add a test that checks the original
getDescription
for code changes. Would you consider adding this change?Docs