umpirsky / Twig-Gettext-Extractor

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

Exception because custom view helper not found #15

Closed aeneasr closed 10 years ago

aeneasr commented 10 years ago

I'm using ZF2 and Twig ( https://github.com/ZF-Commons/ZfcTwig ), when running the extract command

/Library/WebServer/Documents/workspace/athene2/src/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/c3/sys_sm612kg6mph4r640m_bc0000gn/T/poeditCokcyU/65extracted.pot" --from-code=UTF-8  -k_ -kgettext -kgettext_noop -ktranslate -kpageHeader -ksetSubtitle -kaddMessage -kaddSuccessMessage -kaddErrorMessage -ksetLabel -ksetLegend -ksetValue -L PHP --files  "./../../Ui/templates/ads/ads.twig" "./../../Ui/templates/ads/create.twig" "./../../Ui/templates/ads/setAdPage.twig" "./../../Ui/templates/ads/shuffle.twig" "./../../Ui/templates/ads/update.twig" "./../../Ui/templates/application/index/index.twig" "./../../Ui/templates/discussion/discussion/comment.twig" "./../../Ui/templates/discussion/discussion/index.twig" "./../../Ui/templates/discussion/discussion/select/forum.twig" "./../../Ui/templates/discussion/discussion/show.twig" "./../../Ui/templates/discussion/discussion/start.twig" "./../../Ui/templates/discussion/discussions.twig" "./../../Ui/templates/discussion/discussions/index.twig" "./../../Ui/templates/entity/page/aggregate/taxonomy.twig" "./../../Ui/templates/entity/page/article.twig" "./../../Ui/templates/entity/page/course-page.twig"

it results in

Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'The function "pageHeader" does not exist in "/Library/WebServer/Documents/workspace/athene2/src/module/Instance/language/./../../Ui/templates/ads/ads.twig" at line 1' in /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php:553
Stack trace:
#0 /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php(336): Twig_ExpressionParser->getFunctionNodeClass('pageHeader', 1)
#1 /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php(144): Twig_ExpressionParser->getFunctionNode('pageHeader', 1)
#2 /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php(84): Twig_ExpressionParser->parsePrimaryExpression()
#3 /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php(41): Twig_ExpressionParser->getPrimary()
#4 /Library/WebServer/Documents/workspace/athene2/src/vendo in /Library/WebServer/Documents/workspace/athene2/src/vendor/twig/twig/lib/Twig/ExpressionParser.php on line 553

Which is obviously, because the custom method "pageHeader" does not exists in a default twig setup. Is there any way to solve this?

umpirsky commented 10 years ago

@arekkas Please take a look at closed issues: https://github.com/umpirsky/Twig-Gettext-Extractor/issues/2, https://github.com/umpirsky/Twig-Gettext-Extractor/issues/7, https://github.com/umpirsky/Twig-Gettext-Extractor/issues/11...

aeneasr commented 10 years ago

Oh sorry, should have taken a closer look. Maybe add it to the Readme?

However, many thanks :)

umpirsky commented 10 years ago

@arekkas I'm waiting for someone to submit pull request. :trollface:

aeneasr commented 10 years ago

16 there you go ;) Haven't tested it yet, it probably still needs some explanation on how to add more sophisticated extensions