Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel5: How to use @lang in @section?

Tags:

laravel

I normally set my page titles like this:

@section('pageTitle', 'Awesome Page')

I then wanted to change page title based on selected language and tried this:

@section('pageTitle', @lang('my_account.pageTitle'))

However, I get this error:

FatalErrorException in b159db713cb664ba091b07db738bd4c3748de1cb.php line 1: Call to undefined function lang()

What is the correct syntax?

like image 304
Kenneth Poulsen Avatar asked Oct 18 '16 17:10

Kenneth Poulsen


2 Answers

This works it seems, not sure if it's the smartest way to handle it though:

@section('pageTitle', trans('my_account.pageTitle') )
like image 70
Kenneth Poulsen Avatar answered Oct 17 '22 08:10

Kenneth Poulsen


Use something like this:

@section('pageTitle')
    @lang('app.pageTitle')
@endsection
like image 45
RAHUL Avatar answered Oct 17 '22 07:10

RAHUL