Multiple strings with same translation may break form functionality
Today I spent a lot of time tracking why a form did not work and found an issue with translations and a commonly used way of validating forms. In a site with german localization and ecommerce modules I translated a lot of the form submit buttons strings in the checkout process into a generic label "Weiter" (Next in German) and I broke the process. *Why?* Because the "$op" operator is frequently used to check if an action should be performed in a similar way to: <?php switch ($op) { case t('Do something'): ... } ?> And if the translation for 'Do something' just happens to be the same like the translation for another form button in the same series of forms you can guess why it's not working... In my case it was validating an address with the formdata for a shopping cart, and barfed. I don't know if this issue is solved in the forms API for 4.7+ but if it isn't we should look into that. For 4.6 it might be wise to use translations with caution. Regards, Lodewijk Evers Ontwerpwerk multdisciplinary design l.evers@ontwerpwerk.nl http://www.ontwerpwerk.nl
participants (1)
-
lodewijk evers