Skip to content

Commit

Permalink
merged branch andrefgneves/translate-widget-attributes (PR #4194)
Browse files Browse the repository at this point in the history
Commits
-------

23bad29 Added translation to placeholder and title attributes

Discussion
----------

Added translation to placeholder and title attributes

---------------------------------------------------------------------------

by schmittjoh at 2012-05-03T13:52:38Z

Better translate it where it is defined.

Dynamic translations are usually not desirable as they cannot be automatically extracted, and thus require more work.

---------------------------------------------------------------------------

by ruimarinho at 2012-05-03T13:57:30Z

@schmittjoh but isn't that the same case as with labels for instance? I don't think injecting the translator service into the form type would require less work than what this PR suggests.

---------------------------------------------------------------------------

by schmittjoh at 2012-05-03T14:02:02Z

Yeah, same thing.

There might be some cases where it's fine, but in general, we should try to not translate dynamic vars.

---------------------------------------------------------------------------

by ruimarinho at 2012-05-03T14:17:44Z

@schmittjoh I think that's one of those cases, since these attributes in particular (title and placeholder) are intended to aid the user with a brief description. I understand (and agree) with your concern regarding dynamic vars, but in my opinion this is a use case where it is worth it. Just my two cents :)

---------------------------------------------------------------------------

by stof at 2012-05-03T18:07:01Z

@schmittjoh the issue is that translating the label before the template would require injecting the translator in the form types (as the form label can be set there) and would force the user to duplicate the translation process if they pass the label explicitly in the template.
  • Loading branch information
fabpot committed May 22, 2012
2 parents fc34ed1 + 23bad29 commit 5ca64b4
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -305,7 +305,7 @@
{% block widget_attributes %}
{% spaceless %}
id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
{% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
{% for attrname,attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{attrname}}="{{attrvalue|trans({}, translation_domain)}}" {% else %}{{attrname}}="{{attrvalue}}" {% endif %}{% endfor %}
{% endspaceless %}
{% endblock widget_attributes %}

Expand Down

0 comments on commit 5ca64b4

Please sign in to comment.