Use message translations in PHP code
2
If you need to translate something with Rainlab.Translate
in the backend from PHP, use the following code:
use RainLab\Translate\Models\Message;
// use Rainlab's Message translation
$translated = Message::trans('key');
If you need to translate something with Laravel default translation in the backend from PHP, use the following code:
// use default Laravel helper function
$translated = trans('key');
The current locale will be used.
Thank you! It's very helpful. And comment must be at least 50 characters.