umpirsky / Twig-Gettext-Extractor

The Twig Gettext Extractor is Poedit friendly tool which extracts translations from twig templates.
MIT License
113 stars 32 forks source link

asset() and is_granted() does not exist #17

Closed standaniels closed 10 years ago

standaniels commented 10 years ago

When trying to extract as pot file from the templates I get the following errors:

PHP Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "asset" does not exist in "/home/symfony/test-app/vendor/umpirsky/twig-gettext-extractor/../../../app/Resources/views/base.html.twig" at line 7' in /home/symfony/test-app/vendor/twig/twig/lib/Twig/ExpressionParser.php:553

and

PHP Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "is_granted" does not exist in "/home/symfony/test-app/vendor/umpirsky/twig-gettext-extractor/../../../app/Resources/views/menu.html.twig" at line 2' in /home/symfony/test-app/vendor/twig/twig/lib/Twig/ExpressionParser.php:553

Line 7 of base.html.twig is: <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />.

Line 2 of menu.html.twig is: {% if is_granted('ROLE_SITE_OWNER') %}

How can I solve this? I would love to use Poedit to create translations.

umpirsky commented 10 years ago

You must register this extensions as they are not part of standard Twig distribution. Take a look at https://github.com/umpirsky/Twig-Gettext-Extractor#custom-extensions and other issues, it is discussed several times.

umpirsky commented 10 years ago

Maybe we can provide version for Symfony with all Symfony extensions registered. Will think about this.