Internationalization doesn't work in layouts folder

I managed to allow user to change languages, tutorial is very simple and helpful. In


beforeAction()

of my Controller I added


Yii::$app->language="de";

But when I put


  <?= Yii::t('app', 'Change language') ?>

inside


layouts/index.php

where my main template is, it doesn’t translate it, it translates it when Yii::t() is inside “views” folder but not “layout” folder

Hi!

You must do something wrong somewhere.

For me Yii::t() is working everywhere including the layout.

Maybe linking the tutorial you have used would help.

Best Regards

Not sure how, but it’s fixed :)