Did you set in AppServiceProvider's boot():
Pluralizer::useLanguage('french');
?
Hello,
https://laravel.com/docs/12.x/strings#method-str-plural-studly
https://laravel.com/docs/12.x/localization#pluralization-language
Perhaps I forgot some configuration ?
I have tried to change the language to fr in the app.php file, but it doesn't work better.
Well ... it works only if I add Pluralizer::useLanguage('french'); to the AppServiceProvider, but then I also have to change all tables' names. I'd like to activate the pluralizer only for the views.
Thanks for your help.
V
I think you could make a macro
// AppSerivceProvider -> boot()
Str::macro('pluralWithLang', function (string $value, string $lang) {
Pluralizer::useLanguage($lang);
$result = Str::plural($value);
Pluralizer::useLanguage('english');
return $result;
});
And use it:
$plural = Str::pluralWithLang($somestring, 'french');
Please or to participate in this conversation.