Twig i18n support
Is it possible to use the twig i18n extension or has anyone managed to make a different extension that allows us to use gettext/gettext and have php arrays as translation?
{% trans %}
Hey {{ name }}, I have one apple.
{% plural apple_count %}
Hey {{ name }}, I have {{ count }} apples.
{% notes %}
This is shown in the user menu. This string should be shorter than 30 chars
{% endtrans %}
If not, I will have to refactor my code a bit, but I especially liked using the twig variables inside the trans block (gets converted with strtr automatically).
Hi. I'm not familiarized with twig so I don't understand exactly what you want. There's a Twig extractor created by @exnor to capture the translations (see conversation: #71)
I don't want to rely on the php gettext extension.
I'm using that extractor to compile all the twig files and then capture the compiled php classes. Extracting from twig templates and appending to a Gettext\Translations objects is easy and works just fine.
However the problem is that Twig_Extensions_Extension_I18n compiles twig nodes (trans, plural, notes) to use internal php gettext functions(gettext and ngettext), making Gettext\Translator unusable because Gettext\Translator::dpgettext is never being called inside Twig templates.
I guess this is out of scope since it's really a twig question rather than a gettext question. @exnor have you by any chance found a solution?
@rubenvincenten I submitted a pull request to fix this: twigphp/Twig-extensions#160