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

not working with zf2 twig templates #7

Closed yuraigle closed 11 years ago

yuraigle commented 11 years ago

hi, i have *.twig files with several zf2-specific helpers like {{ doctype() }}, {{ headMeta() }} etc.

trying to parse them with poedit throws

PHP Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "docType" does not exist in "/var/www/kai/zapp/module/Application/language/../view/layout/layout.twig" at line 1' in /var/www/kai/zapp/vendor/twig/twig/lib/Twig/ExpressionParser.php:555

is there any way to ignore these functions?

umpirsky commented 11 years ago

Hi, thanks for using Twig Gettext Extractor!

You can copy twig-gettext-extractor to your project (e.g. bin/twig-gettext-extractor) and register this zend extensions here.

You can do same for custom extensions you wrote.

If this helps please close this issue, if not, don't hesitate to ask for further assistance.

yuraigle commented 11 years ago

i've added

$twig->addFunction(new \Twig_SimpleFunction('docType', true));
$twig->addFunction(new \Twig_SimpleFunction('headMeta', true));
...

there, and it helps to avoid error. thx

umpirsky commented 11 years ago

:+1: