0

I've joined new project of website in Symfony3 framework and now I'm struggling an issue, trying to figure out this particular syntax in Twig:

<li><a href="{{ path('contact') }}">{{ 'site.template.menu.contact'|trans }}</a></li> 

Arguments in path() twig function have name of route in my SiteController but i totally don't know what does code between <a/> tags, except 'trans' filter. I don't have any variables in my twig template file.

Have you seen something like this before? Where I should find information about this in docs or how to name syntax like this to find some information?

1

1 Answer 1

3

It is just the twig "internationalization" (often abbreviated i18n). Docs for it are here.
The quotes around the object shouldn't be there. I'm assuming that an object called site is being passed to the view, so it should be {{ site.template.menu.contact|trans }}

To explain the dot notation in twig; If your PHP array is something like;

$site['template']['menu']['contact'] = 'fubar'; 

If it is an object then it is just attributes of the object.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi, thanks a lot! However I want to know where refers this line with Dot notation: 'site.template.menu.contact'?
@MichaelKowalewsky in your controller that call the view, just dump($site) to see what the object is and what it contains.
I don't think that is an object, but a string to be translated. This is common, using identifiers for tranlsation keys instead of the site's primary language.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.