views:

43

answers:

1

Hi there,

My application has a form with 2 submit buttons:

<input name="rating" class="Show" type="submit" value="Show answer"> 
<input name="rating" class="Skip" type="submit" value="Skip">

However I noticed some errors in GAE logs:

ValueError: invalid literal for int() with base 10: 'Voir la r\xe9ponse'
ValueError: invalid literal for int() with base 10: 'Sauter'

Basically it's the value of the form buttons, in French, whereas my app is in English. How can a user change the form submit values? For example with google translate etc? How can I handle this?

+1  A: 

Yeah, that'll be Google Translate. It translates the text on the buttons as well. If you really want to prevent this, you'll have to make sure Google can't translate the text on the button. Note: these answers are not semantic HTML. Not sure if there's a cleaner method, I hope so, but this is what first springs to mind:

Method 1: hidden inputs

Since you're using buttons anyway, you might as well have them submit something. Put each button in its own form, add a hidden field, and use the value of the hidden field to determine what page to load next.

Downside: a lot of extra html, not really maintenance-friendly

Method 2: numeric value

Change the value of the buttons into something numeric, like 0 and 1. Hide the button's value with CSS and give the button a background image that shows the text. Load the page based on the numeric value.

Downside: very bad accessibility (screen readers, etc.), text on button won't be translated.

I really do hope there's better alternatives I haven't thought of yet.

Litso
Method 3: use the google translate API to translate all your button text into every language they support, and check for all of those on receiving the form. Maybe not.
Steve Jessop
Hehe, I considered that too but I figured it'd be a waste to even post it. Just too much work to do something like that.
Litso