Aleš Sýkora / February 8, 2024 / 0 comments
Integrate Bookolo with TranslatePress languages
2 min read / TranslatePress, Uncategorized, WordPress / Share on: Twitter, LinkedIn, Facebook
Post summary: How to dynamically add the current site language into Bookolo script.
If you use Bookolo booking within your WordPress site, then you have already integrated the scripts for it. However, if you use TranslatePress plugin, you would like to dynamically change the language of Bookolo with your site language options.
- Bookolo integration manual: Dokumentace pro integr… | Bookolosystem Wiki
Bookolo form
Don’t forget to add your hotel-id!
<?php
$locale = get_locale(); // get language code - for example 'cs_CZ'
$current_language_code = substr($locale, 0, 2); // get only first two chars - 'cs'
?>
<div id="bookolo-engine" data-hotel-id="xxx" data-cookieconsent="performance,marketing" data-language="<?php echo $current_language_code; ?>" data-currency="CZK"></div>
You may need to change the currency too:
<?php
$locale = get_locale();
$current_language_code = substr($locale, 0, 2);
// Change currency based on language
if ($current_language_code == 'cs') {
$currency = 'CZK';
} elseif ($current_language_code == 'en') {
$currency = 'EUR';
} elseif ($current_language_code == 'de') {
$currency = 'EUR';
} else {
// Default currency
$currency = 'CZK';
}
?>
<div id="bookolo-engine" data-hotel-id="xxx" data-cookieconsent="performance,marketing" data-language="<?php echo $current_language_code; ?>" data-currency="<?php echo $currency; ?>"></div>
Bookolo banners
Don’t forget to add your hotel-id!
<?php
$bannerlocale = get_locale(); // get language code - for example 'cs_CZ'
$banner_current_language_code = substr($bannerlocale, 0, 2); // get only first two chars - 'cs'
?>
<script>
var bookolo = {
hotel: xxx,
language: '<?php echo $banner_current_language_code; ?>' // language code
};
</script>
<script src="https://www.bookoloengine.com/v3/bookolo-all.min.js"></script>
Fuel my passion for writing with a beer🍺
Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻