Hi,
Here are some ways I thought to translate strings in template.
Using the custom template tags:
add_filter('wpbe_tags', function( $tags ) {
// Set the current language, fallback to english by default
$lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : 'en';
// Set a translations array
$translations = array(
'footer.email_sent_on' => array(
'en' => 'Email sent on',
'fr' => 'Email envoyé le',
),
'footer.mention' => array(
'en' => 'Please only print this email if necessary',
'fr' => 'N’imprimez cet email que si nécessaire',
),
);
// Create new tags
$tags['footer.email_sent_on'] = $translations['footer.email_sent_on'][$lang];
$tags['footer.mention'] = $translations['footer.mention'][$lang];
return $tags;
}
You should then be able to use tags such as %footer.mention% and %footer.email_sent_on% in your template. They will be translated.
Using the templates tags and the translation files:
add_filter('wpbe_tags', function( $tags ) {
// Create new tags
$tags['footer.email_sent_on'] = __('Sent on', 'theme_text_domain');
$tags['footer.mention'] = __('Please only print this email if necessary', 'theme_text_domain');
return $tags;
}
Probably cleaner. If you don’t have a translation file, create one and load it manually.