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

Some strings ('No input') in code are not internationalized (Validators too) #204

Open
idgserpro opened this issue Sep 29, 2017 · 1 comment

Comments

@idgserpro
Copy link
Contributor

idgserpro commented Sep 29, 2017

We're using 1.7.x, don't know if there are problems like this in 5 as well. We have:

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/skins/PloneFormGen/fg_result_embedded_view.pt#L6

<dd tal:content="python:request.form.get(fname, 'No Input')" />

No input here should be internationalized. Which is the best way in this kind of context (a python code in a tal template?)

Some other files that we have this 'No input' references:

skins/PloneFormGen/fg_testresult_view.pt
content/fieldsBase.py
content/formLikertField.py
content/fields.py
content/thanksPage.py
content/formMailerAdapter.py

Is this 'No input' being used as a constant instead, since we have https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/content/thanksPage.py#L258?

if self.includeEmpties or (value and (value != 'No Input')): 

The validators have the same problem:

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/validators/BooleanValidators.py#L28

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/validators/CaptchaValidator.py#L27

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/validators/ExRangeValidator.py#L46

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/validators/MaxLengthValidator.py#L46

https://github.com/smcmahon/Products.PloneFormGen/blob/1.7.23/Products/PloneFormGen/validators/TextValidators.py#L40

@idgserpro idgserpro changed the title Some strings ('No input') in code are not internationalized Some strings ('No input') in code are not internationalized (Validators too) Oct 10, 2017
@mauritsvanrees
Copy link
Collaborator

I have not tried it, but nstead of this:

<dd tal:content="python:request.form.get(fname, 'No Input')" />

probably this works:

<tal:block define="value python:request.form.get(fname, None)">
  <dd tal:condition="python:value is not None" tal:content="value" />
  <dd tal:condition="python:value is None" i18n:translate="">No Input</dd>
</tal:block>

I guess this dd from fg_result_embedded_view.pt does not end up in the request, so the check in the thanks page should be fine.

For the validators, maybe simply returning _(...) already works, which would be good. Otherwise you might need to explicitly call zope.i18n.translate on the error string before returning it.

Pull requests are welcome.

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