On 1/2/11 3:19 PM, Jordi Boggiano wrote:
Heya,
I'm having some concerns with regard to how translations are working at
the moment, let me explain with this twig code:
Translates "Hello firstname" and then replaces firstname by foo from the
resulting translated string<br />
{% trans 'Hello firstname' with {'firstname': 'foo'} %}<br />
You can also write:
{% trans 'Hello {{ firstname }}' with {'{{ firstname }}': 'foo'} %}
My choice of re-using {{}} for placeholders was probably not the best
idea I had. I have an item on my todo-list to change this placeholder
notation for quite some time now and this thread made me work on that
again today.
Basically, I have replaced {{ foo }} with %foo%, and it's indeed much
better as it requires less hacks and made things more flexible. You can
for instance now have something like:
{% trans 'Hello %firstname%' %}
and Symfony2 will automatically add the firstname variable to the list
of arguments (the implicitness was not possible with the {{}} notation).
You can have a look at the implementation in the translation branch on
github:
https://github.com/fabpot/symfony/commit/83f5ec9a9dc763d00d88db5c705625aef98cd4fe
If you agree that this is indeed better, I will merge the branch.
Fabien
Translates "Hello firstname" and then replaces firstname by foo from the
resulting translated string<br />
{% trans with {'firstname': 'foo'} %}Hello firstname{% endtrans %}<br />
Translates "Hello {{ firstname }}" and then replaces {{ firstname }} by
foo from the resulting translated string<br />
{% set firstname = 'foo' %}
{% trans %}Hello {{ firstname }}{% endtrans %}<br />
Assuming you have a messages.en.yml file containing:
"Hello firstname": FOO firstname
"Hello {{ firstname }}": FOO {{ firstname }}
Then the above code outputs three times "FOO foo".
However as we see there is a difference between the two first syntaxes
(using the first line from messages.en.yml) and the last one using the
second line.
What I would like to see is some unification. They should imo all use {{
firstname }}, so {{ / }} should be added to all the parameter names.
Ideally I would prefer %firstname% because it's shorter and less
sensitive for translators to keep well formatted (it doesn't have any
whitespace).
Cheers
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en