M
M
Maxim js2022-01-21 12:04:39
PHP
Maxim js, 2022-01-21 12:04:39

How can I use dynamic route in Laravel localization?

<?php
return array (
  'Accept Cookies' => 'Accept Cookies',
  'Cookie info' => 'Please be informed that we use cookies to enhance your user experience. For a complete overview of all cookies used, please see our <a href="{{ route('frontend.pages.cookies')  }}" class="hero_side__link">Cookies Policy</a> and <a href="{{ route('frontend.pages.privacy')  }}" class="hero_side__link">Privacy Policy</a>.',
);

throws an error because of the quotes 'frontend.pages.cookies' but I need to use them without them the link does not work
how to resolve these quotes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2022-01-21
@winers

return array (
  'Accept Cookies' => 'Accept Cookies',
  'Cookie info' => 'Please be informed that we use cookies to enhance your user experience.
      For a complete overview of all cookies used, please see our
      <a href="'.route('frontend.pages.cookies').'" class="hero_side__link">Cookies Policy</a>
      and <a href="'.route('frontend.pages.privacy').'" class="hero_side__link">Privacy Policy</a>.',
);

But I think it's better to use substitutions
return array (
  'Cookie info' => 'Please be informed that we use cookies to enhance your user experience.
      For a complete overview of all cookies used, please see our
      <a href=":policy_url" class="hero_side__link">Cookies Policy</a>
      and <a href=":privacy_url" class="hero_side__link">Privacy Policy</a>.',
);

{{! __('Cookie info', [
  'policy_url' => route('frontend.pages.cookies'),
  'privacy_url' => route('frontend.pages.privacy'),
]) !}}

U
Ukrainskiy, 2022-01-21
@Ukrainskiy

Escape\'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question