October CMS resources and help articles

Simple and to the point. Optimized by the community.

Use message translations in PHP code

1
by mjauvin, last modified on August 12th, 2019

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.

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?