Ok, I’ve been working on a site upgrade/redesign for several days. Four languages, cookies, random images and other goodies. Fairly straightforward stuff.
Late last night I worked out how to use a single eForm template for all four languages. Add my form prompts to the language files, then create a nice little function for the eFormOnBeforeFormMerge event:
<?php
function setPrompts(&$fields) {
global $_lang;
$fields['yourname'] = $_lang['yourname'];
$fields['youremail'] = $_lang['youremail'];
$fields['yourmessage'] = $_lang['yourmessage'];
$fields['sendmessage'] = $_lang['sendmessage']; // for the submit button
return true;
}
?>
Works like a charm... except for the German form. Blank page. After banging my head against the wall for a while, I gave it up and went to bed. This morning I got back to it, and picked apart my code, from the snippets setting and getting the user’s language choice to and from a cookie, to the site template and the eForm template.
Then I sat back and said to myself "The only difference between this German page and the other three languages is that I’m setting the &language value in the eForm snippet call to `german` instead of `english` etc. Then the light went on... the german language file!!! And there it was... one of the entries was missing its ending semicolon.