2017-04-20 31 views
1

我在Laravel在多語應用工作5.4通@lang作爲@section參數Laravel

template.blade.php

<title>@yield('title')</title> 

然後在其他網頁,我想設置基於用戶區域設置dyamically。它拋出的錯誤,當我嘗試使用以下命令:

@section('title',{{ __("dashboard") }}) 

@section('title', @lang("dashboard")) 

這是錯誤:

Parse error: syntax error, unexpected '<' 

任何一個可以告訴如何通過@lang__('')作爲paramater在@section()

回答

2

你有什麼作爲參數是假設php。因此,當您放置@lang或{{}}時,它會在已打開的php標記內打開php標記。
因此,你可以做的只是把__()沒有括號。就像那樣:

@section('title', __('dashboard')) 
1

您可以使用的而不是lang裝飾:

@section('title', trans("dashboard")) 

或者

您還可以使用__功能如下:

@section('title', __("dashboard")) 

你不需要因爲你不使用它使用{{}}在另一個指令內。