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
Form Widget Translations #8
Comments
humm, i am using FOSUserBundle with Bootstrap bundle too. i have seen differences maybe its from that. |
Just in the template, for example at the top of edit_content.html.twig:
|
hmm first of al can you check if translation is working at all? framework:
...
translator: { fallback: de }
...
session:
default_locale: %locale%
auto_start: true i have a simple test setup here, i will try to extens it with fosuserbundle tonight and check, atm i cant see any reason for that in BootstrapBundle ... |
Yes, working. It's only a problem with The problem goes away altogether if I disable the twig configuration, eg:
|
humpf ... i will check that ... no idea right now where that comes from |
humm this is really strang ... template looks like that: {% form_theme form theme %}
Mine
<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" />
</div>
</form> and i get the output as expected: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
</head>
<body>
<div>
<a href="/app_dev.php/login">Login</a>
</div>
<div>
Mine
<form action="/app_dev.php/register/" method="POST" class="fos_user_registration_register">
<div id="fos_user_registration_form">
<fieldset>
<input type="hidden" id="fos_user_registration_form__token" name="fos_user_registration_form[_token]" value="4237147b6b29a72cb1feabc72ae53678a3dc024f" /><div class="clearfix "><label for="fos_user_registration_form_username" class=" required">
Username
*
</label><div class="input"><input type="text" id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="255" pattern=".{2,255}" value="" /><span class="help-block"></span></div></div><div class="clearfix "><label for="fos_user_registration_form_email" class=" required">
Email
*
</label><div class="input"><input type="email" id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required" value="" /><span class="help-block"></span></div></div><div class="clearfix "><label for="fos_user_registration_form_plainPassword_first" class=" required">
First
*
</label><div class="input"><input type="password" id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required" value="" /><span class="help-block"></span></div></div><div class="clearfix "><label for="fos_user_registration_form_plainPassword_second" class=" required">
Second
*
</label><div class="input"><input type="password" id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required" value="" /><span class="help-block"></span></div></div>
</fieldset>
</div>
<div>
<input type="submit" value="Register" />
</div>
</form>
</body>
</html> |
could you please check you have up -to date symfony and fosuserbundle |
btw is your bundle defined as child of fosuserbundle ? or how do you overwrite the templates? also in app/Resources? |
I'm pretty sure both are up-to-date. What happens when you try to override the translation? For example, add this to
where translator fallback is "en". |
Can you elaborate on what you mean by "child of fosuserbundle"? The User entity in my UserBundle does extend FOS\UserBundle\Entity\User. |
okokok :) first of all to the thinks above : Now to the problem source ... {{ id|trans([], 'FOSUserBundle') }} (if you want to have a look into vendors/bundles/FOS/UserBundle/Resources/views/form.html.twig ... but since we are using the config option in config.yml to get BootstrapForm Theme this one here wont get used, so the nice translation namespace isnt used so the labels arent translated :( And now some solution, i am not sure right now what would be the best, but i assume some Attribute on the form, where it sould take the namespace from, would do it, or perhabs something like to get the namespace into our form rendering template if you have any ideas they are very welcome, i will now try getting a fast solution up. probably not the best but at least to solve the prob for now. |
OK i found our field_label_attr_aware_label using generic label instead of field label ... so now our attr merging also can be extended the way fosuserbundle does it and it should be solved ... please pull and reopen this ticket if it doent work for you |
Yep, that fixes it. Thanks a ton! |
np you're welcome! |
I have the exact same issue and I can't understand how to solve it. Can you elaborate a little on the solution ? |
@alch3m1st what exatly is the prob atm ? what solved it? |
The labels used in the registration form by the FOSUserBundle (as nurikabe describes) are not translated (according to FOSUserBundle.en.yml,the config.yml translation fallback is EN). My bundle extends FOSUserBundle using getParent and my app uses MopaBootstrapBundle:Form:fields.html.twig form theme from MopaBootstrapBundle. |
which form exactly ? |
My bundle extends this form I remove this part
to extend the form using the default MopaBootstrapBundle:Form:fields.html.twig and now I get the desired theme but loose the traslation. This snippet here https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/form.html.twig must be responsible for the translation of the labels on the FOSUserBundle...but I am not sure how to fix it using MopaBootstrapBundle form theme |
humm i use bundle extension (overriding getParent) and that works perfect .... |
I have followed the docs and extended my bundle using FOSUserBundle (translation files, controllers, templates), because I needed some customization. I have copied this template to my bundle in order to extend it :
This is what i get : I remove the form theme in order to use the mopabootstrapbundle (i use the config.yml directive)
This is what I get: But I need a proper rendering + translation. |
ot sure if i got you completely right, i have the same result as in pic two, but the translation is english and you need another one, can you explain me how i can most easily switch to another one? and do i need your translation files for that? but i thats just what i remember, probably we can find that out together... |
I just need to define my labels. If I ignore the translation files I could:
e.g.
e.g
If i wanted to use the translation files, I could:
something like this...
All the abode techniques work (except from 4 which I have not tried yet) Is there any other _easier_ way to use the translation files (And I mean the ones that I extended from FOSUB)? |
I believe I resolved it (maybe the way you suggested before this issue was closed first time): Inside my bundle's layout.html.twig (which extends FOSUserBundle and uses MopaBootstrapBundle form theme) I extended the label field :
Now I have both the translation and the proper form theme. I did this because FOSUserBundle extends the default SF2 form theme and changes label to id (in order to user is as a translation key). https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/form.html.twig @phiamo I don't know why this worked of you out of the box. Thank you for you time and MopaBootstrapBundle. |
hmm this isnt too nice ... i will have that in mind, i need it soon to ... maybe i can come up with a proper solution, but for the moment i believe your prob is solved |
Also you can try using both themes to render form:
|
Hello I'm traying to resolve this translation issue but no way ! I'm using version 2.0.x and it seems to me that solution has been applyed in the master branch only !? isn't it ? In case I am right, could you please apply on the 2.0.x branch !? Or explain to me how I could apply myself ? In case I am wrong, could you re-explain to me how you solved this issue ? Thank u very much by advance ! :)) |
Form widget labels from FOSUserBundle, eg:
no longer translate when activating MopaBootstrapBundle:Form:fields.html.twig for the whole project. MopaBootstrapBundle:Form:fields.html.twig doesn't seem to know how to translate them.
The text was updated successfully, but these errors were encountered: