Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Use message translations in PHP code

0
by mjauvin, last modified on March 30th, 2023 - Previously published on OctoberTricks

If you need to translate something with Rainlab.Translate in the backend from PHP, use the following code:

use Winter\Translate\Models\Message;

// use Winter'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?