lang multi Language in laravel not work in controller.I use ajax query database in Controller,I need to use lang in controller return to view but output not translate Language such as
public function a2($id)
{
echo '<h1>'.@lang('home.text').'</h1>';
echo '<p>content from query data</p>';
}
success: function (data) {
document.getElementById("response").innerHTML = data;
}
<div id="response"></div>
@lang('home.text')
content from query data
@lang() is for blade, use __()
public function a2($id)
{
echo '<h1>'.__('home.text').'</h1>';
echo '<p>content from query data</p>';
}
You can use __
helper function in controllers:
public function a2($id)
{
echo '<h1>'. __('home.text').'</h1>';
echo '<p>content from query data</p>';
}
Can you try this
Lang::get('home.text')
instead of
@lang('home.text')