I'd like have something like this in the lang/en/mymsgs.php
'string1' => 'Welcome %1, Please meet %2'
I would provide the content for %1 and %2 when getting the 'string1' from my code.
I couldn't find a way to do this. Any pointers?
Laravel message localization uses named, not numeric, parameters.
Rewriting your example message:
'string1' => 'Welcome :user, Please meet :other',
You can now use, for example:
trans('string1', [ 'user' => 'Ainsley', 'other' => 'Hayden' ]);
If anyone use string translation for Laravel. They can use like this -> __('Some translatable string with :attribute',['attribute' => $attribute_var])
check the documentation for more https://laravel.com/docs/5.7/localization#using-short-keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With