Gettext translation of Volt templates

I try to make translations in my Volt-templates, but I can't make it work.

In my config/services.php I have added the following in my view component to allow "gettext" function in the templates: $compiler = $volt->getCompiler(); $compiler->addFunction('', '');

Template example: {{ _('Username') }}

When I run xgettext, gettext statements from the PHP-files is OK, but it don't find the Volt-translations: xgettext -k_ -kgettext --from-code utf-8 -d kitcloud -o kitcloud.pot -L PHP --no-wrap $(find ../ ! -path '../cache/' ! -path '../sources/' -name ".php") $(find ./views -name ".volt")

First I tried the Gettext adapter from https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Translate/Adapter. Same problem.

Any idea how to do this?



30.7k

Hi, 1/ I've tried my best with the use of xgettext command: it never had extract any string from a volt file ..... A workaround I d'idn't tried: use xgettext on the php generated files by volt compiler ... 2/ Maybe, have a look here: http://forum.phalconphp.com/discussion/1150/need-help-with-gettext-solved- for /Phalcon/Translate/Adapter configuration ...

Thanks! I tried the method you are mentioning, translating the generated volt-files. The problem is you'll have to visit/compile every page when you are going to translate.. I go for the NativeArray-adapter.