Resolved: I need to pass the Localization String with this syntax:
:page-title="__('Password dimenticata')"
Localization in Component parameter: "syntax error, unexpected token "endif", expecting end of file"
Hello, I'm making a Laravel 8 based app.
I've made my base layout as a Laravel Component, and I'm passing as parameters things like the page title. I'm also using the Localization strings to make it multi-language, but when I pass to my component a parameter containing a localization string, I get this error:
syntax error, unexpected token "endif", expecting end of file
This is the content of the blade view:
<x-auth-layout page-id="forgot-password" page-title="{{ __("Password dimenticata") }}">
<div class="row justify-content-center">
<div class="col-lg-6 text-center">
<h2 class="mb-4">{{ __("Non temere, puoi recuperarla") }}</h2>
<p class="big">{{ __("Inserisci la tua email per ricevere un link e le istruzioni nella tua casella di posta. 5 minuti al massimo e potrai accedere nuovamente.") }}</p>
</div>
</div>
<div class="row justify-content-center mt-4">
<div class="col-lg-4">
<div class="input-unit mt-4 mb-5">
<label for="email" class="form-label">{{ __("La tua email") }}</label>
<input type="email" class="form-control" id="email" name="email" placeholder="[email protected]">
<small class="form-text">{{ __("Usata per la registrazione") }}</small>
</div>
<div>
<input type="submit" class="btn btn-tertiary w-100" value="{{ __("Richiedi le istruzioni") }}">
<a href="#" class="btn btn-primary-transparent w-100 mt-4">{{ __("Ho dimenticato anche l’email") }}</a>
</div>
</div>
</div>
</x-auth-layout>
And this is the component file:
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AuthLayout extends Component
{
public $pageTitle;
public $pageId;
/**
* Create the component instance.
*
* @param string $type
* @param string $message
* @return void
*/
public function __construct($pageTitle, $pageId)
{
$this->pageTitle = $pageTitle;
$this->pageId = $pageId;
}
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
$data = [
"pageTitle" => $this->pageTitle,
"pageId" => $this->pageId,
"layoutType" => "auth"
];
return view('layouts.app', $data);
}
}
And this is the app layout view:
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ $pageTitle }}</title>
<!-- Mix Compiled Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
<!-- Mix Compiled JS -->
<script src="{{ asset('js/app.js') }}" defer></script>
<!-- Livewire Styles -->
@livewireStyles
</head>
<body id="{{ $pageId }}">
<!-- Header -->
@switch($layoutType)
@case("auth")
<header class="container-fluid auth">
<div class="col-lg-12">
<img class="logo" src="{{ asset('images/logo.svg') }}" />
</div>
</header>
@break
@case("logged")
@include('layouts.partials.header')
@break
@endswitch
<!-- Page Content -->
<div class="container">
{{ $slot }}
</div>
@include('layouts.partials.footer')
<!-- Livewire JS -->
@livewireScripts
</body>
</html>
Where I'm wrong? I noticed that if i delete the content in page-title="{{ __("Password dimenticata") }}" with something "static" the error disappears.
Please or to participate in this conversation.