template}.privacy.Privacy-en") @include("frontend.{$config" /> template}.privacy.Privacy-en") @include("frontend.{$config" /> template}.privacy.Privacy-en") @include("frontend.{$config"/>

problem with @include file in template (laravel)

145 Views Asked by At

I'm trying to include many files to a blade file with dfr lang

@include("frontend.{$config->template}.privacy.Privacy-en")
@include("frontend.{$config->template}.privacy.Privacy-es")
@include("frontend.{$config->template}.privacy.Privacy-de")
.
.
.

I want one of these files to be imported according to the language chosen by the visitor

So I wrote this code as follows in page.blade.php

@include("frontend.{$config->template}.privacy.{'Privacy-' . LaravelLocalization::getCurrentLocale()}")

The error:

No hint path defined for [frontend.nova.privacy.{'Privacy-'. LaravelLocalization]. (View: C:\xampp\htdocs\templates\frontend\nova\page.blade.php)

any help will be highly appreciated.

1

There are 1 best solutions below

0
Giles Bennett On BEST ANSWER

Simple answer is don't do it this way. Laravel has built-in support for localisation, so there is no need to build different pages for each language and then jump through hoops - as you are trying to do - to try and incorporate the relevant one.

Read the documentation about localisation - in short, set up one blade template (called 'privacy.blade.php' for example) and within it use short keys such as :

{{ __('privacy.introduction') }}

and then define those keys within the relevant language files (so resources/lang/en/privacy.php, /fr/privacy.php, and so on) :

return [
    'introduction' => 'The following statements set out our privacy information',
];