Issue
Why would i18n translations work in a view
, but not in AppController
?
Doesn't work - In AppController
:
class AppController extends Controller
{
public function initialize()
{
parent::initialize();
debug(__('My English Text'));
...
}
}
Works - In my view
:
<p><?= __('My English Text') ?></p>
Solution
I simply had to set the language before calling __()
. In my case, it was being set further down the chain in initialize()
within AppController
.
Answered By - TechFanDan
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.