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

Translation does not work for button used within common layout #960

Open
monim67 opened this issue Jan 5, 2020 · 1 comment
Open

Translation does not work for button used within common layout #960

monim67 opened this issue Jan 5, 2020 · 1 comment

Comments

@monim67
Copy link

monim67 commented Jan 5, 2020

  • Package version: 1.8.1
  • Django version: 3.0.1
  • Python version: 3.7.6
  • Template pack: (Optional)

Description:

Translation does not work for button text when used within a common layout as described in the docs here. The translation does not update as it should when the language is changed.

Steps to reproduce:

  • Go to this heroku app.
  • Switch the language using language selection links at the bottom.
  • Language updates for the whole page except for the button text.

See the source code of it here on GitHub using common layout for buttons.

Why this happens:

This happens because when BaseInput class of crispy-forms renders it converts the lazy django translation object passed as value to string and stores it back to value overwriting it here, hence the lazy translation object is lost upon the first render of the input element. If we don't overwrite the original value the issue is resolved.

@tobiasmboelz
Copy link

This is not limited to the buttons in a common layout. The problem exists for all Buttons/Submits used in any layout.

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

2 participants