Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with TWIG ~1.24 #47

Open
cheplv opened this issue Oct 11, 2016 · 8 comments
Open

Not working with TWIG ~1.24 #47

cheplv opened this issue Oct 11, 2016 · 8 comments

Comments

@cheplv
Copy link
Contributor

cheplv commented Oct 11, 2016

Due to changes of twig translations method in generated PHP templates - need to add correct keyword.
Current translation string looks like: $this->env->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslator()->trans("Greeting.", array(), "messages");

I'v solved this with changing language parameter with keyword parameter.
Command looks like:
twig-gettext-extractor --sort-output --force-po -o messages.pot --keyword="trans" --files cat /tmp/tempfile

@umpirsky
Copy link
Owner

Thanks!

We should handle this. PRs are welcome. :)

cheplv pushed a commit to cheplv/Twig-Gettext-Extractor that referenced this issue Oct 11, 2016
Add support for trans and transchoice
@cheplv
Copy link
Contributor Author

cheplv commented Oct 11, 2016

Added new PR.

@cheplv
Copy link
Contributor Author

cheplv commented Oct 11, 2016

There was one more thing: transchoice function

@drzraf
Copy link

drzraf commented Dec 9, 2016

Wow! Great.
Tested: it solved the issue for me.
thx

@drzraf
Copy link

drzraf commented Dec 9, 2016

But note, that this construct does not seem to be recognized (not converted from Twig to PHP):

Submitted by %author_name% on %date%|trans({'%author_name%': author_name, '%date%': date})

@drzraf
Copy link

drzraf commented Dec 9, 2016

Also this fails too:

{% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}

with

Twig_Error_Syntax: A message inside a trans tag must be a simple text

While it should not.

But this:

{% trans with {'%author_name%': author_name, '%date%': date} %}

works

@cheplv
Copy link
Contributor Author

cheplv commented Dec 12, 2016

There was changes in twig relating translation, this cause me open this ticket :)
More info: http://symfony.com/doc/current/translation.html
Need to make investigation on this generated code:
Submitted by %author_name% on %date%|trans({'%author_name%': author_name, '%date%': date})

@umpirsky
Copy link
Owner

Are you sure this is Twig specific and not Symfony specfic? Because you linked Symfony documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants