setting a placeholder attribute with translation in Symfony2 form input

In Twig you shouldn't put {{ within {{ (same for {%); think of it as the php tag.

The following should work

{% set usernameplaceholder = 'security.login.usernameplaceholder'|trans %}
{{ form_widget(form.username, { 'attr': {'class': "span12",
    'placeholder': usernameplaceholder} }) }}

OR

{{ form_widget(form.username, { 'attr': {'class': "span12",
    'placeholder': 'security.login.usernameplaceholder'|trans} }) }}

For Symfony 3.x, 4.x

Another way to add placeholders (or any attributes for that matter) is by passing an options-array to the form $builder containing another Array attr with attributes as key-value pairs.

// The parameters are column name, form-type and options-array respectively.
$builder->add('field', null, array(
            'attr' => array(
                 'placeholder' => 'support.contact.titleplaceholder'
             )
        ));