zerospam / laravel-gettext

Adds localization support to laravel applications using PoEdit and GNU-Gettext.
99 stars 56 forks source link

vsprintf(): Argument #2 ($values) must be of type array, null given #52

Open djlimix opened 3 years ago

djlimix commented 3 years ago

When using _s() function, it fails when you do not provide third parametre, $args.

Error message:

vsprintf(): Argument #2 ($values) must be of type array, null given

Example code:

$diff = $created->diff($now)->days;
return $diff . ' ' . _s('{0} 0 day|]1,4[ days|]4,Inf[ days', $diff)

Laravel version: 8.39.0 PHP version: 8.0 LaravelGetText version: dev-master (also tried it on 8.0.2)

However, when I add the third parametre, even only an empty array, it works.

redalpha01 commented 3 years ago

Not a fix but I suggest providing an empty array until this is fixed.

redalpha01 commented 3 years ago

The offending line is 112 in helpers where it defaults to null instead of empty array.

djlimix commented 3 years ago

Not a fix but I suggest providing an empty array until this is fixed.

I am providing an empty array, I just wanted to report this.