function add_shortcode_based_on_language($content) {
// Detect the current language (example for Polylang)
if (function_exists('pll_current_language')) {
$current_language = pll_current_language(); // Get the current language code (e.g., 'en', 'fr', 'es')
// Add the shortcode conditionally based on the language
if ($current_language === 'en') {
$content .= do_shortcode('[mwai_chatbot id="default"]'); // For English
} elseif ($current_language === 'fr') {
$content .= do_shortcode('[mwai_chatbot id="french"]'); // For French
} elseif ($current_language === 'es') {
$content .= do_shortcode('[mwai_chatbot id="spanish"]'); // For Spanish
}
}
return $content;
}
add_filter('the_content', 'add_shortcode_based_on_language');