I am using WPML to translate English to a different language. Everything works fine except the mail form. For some reason when is use the _e() function the string gets printed before the layout. But still inside the body element. Please help here is the code:
if(trim($_POST['contactSubject']) === '') {
$subjectError = _e('Please enter a subject.', 'wpml_contact');
$hasError = true;
} else {
$subject = trim($_POST['contactSubject']);
}
You should use the __()
function (codex link). This function returns the translated string:
if(trim($_POST['contactSubject']) === '') {
$subjectError = __('Please enter a subject.', 'wpml_contact');
$hasError = true;
} else {
$subject = trim($_POST['contactSubject']);
}
The _e()
function returns and displays the translated string.