Open Langmans opened 8 years ago
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
https://github.com/elcreator/tempot can be used to extract without the need to compile twig to PHP (i.e. if you haven't proper PHP environment where you have the project files).
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?
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).