2016-10-11 03:08


I was just going thorugh one of the twig files in the bolt default theme template and i came across the following line of code:

{{ __("Unfortunately, no content could be found. Try another page, or go to the <a href=\"%paths_root%\">homepage</a>.", {'%paths_root%': paths.root} ) }}

Now i taught the way you echo something in twig is as follows:

{{ 'hello there' }}

I googled double underline and found this HERE. Not sure thats the answer to my question.

So what exactly is the double underline in twig or bold ??

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dsnhalq37505 dsnhalq37505 5年前

    In current stable Bolt version, __() is a Twig function to call our translation layer, that sits on top of Symfony's.

    The second parameter in that function is the value in the string that is variable, and the value you want inserted in its place for that specific translation string, at that point.

    点赞 评论 复制链接分享
  • duanqiao9541 duanqiao9541 5年前

    Im not sure if I understand this correctly but in Symfony framework for translations of strings you should use the translator service.

    Then you could use the trans and transchoice Twig tags.

    Please see Symfony documentation for more details : Symfony translations

    点赞 评论 复制链接分享