Warm tip: This article is reproduced from stackoverflow.com, please click
html laravel laravel-blade localization php

Localisation of Page Titles with laravel

发布于 2020-03-29 21:01:00

I have the main page where I yield the title like this:

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

Now I want to use this on my pages, but I want it to be localized, so I have the lang folder with two languages - en & ru, inside of which I have a file called 'titles.php', where I keep my titles.

The problem is that if I try to use something like

@section('title', {{__('titles.faq')}})

on my page it throws an error immediately. Is there any way to do that? What am I doing wrong?

Questioner
Mike L.
Viewed
43
Jerodev 2020-01-31 18:32

There is no need to use the curly brackets in a blade function, they are evaluated as plain php code:

@section('title', __('titles.faq'))