Translations
This page covers two separate topics:
- BidJS translations — built into BidJS: optional sync with your page language
via
<html lang>(see below). - Weglot — a third-party translation product, not part of BidJS. Use the Weglot section only if you integrate that service on your site.
By default, if translated content is available in your BidJS instance, the platform will display content based on the user’s browser language settings. For example, if English and French are configured and a user’s browser is set to French, the French content will be shown.
To override this automatic language selection, possibly by using a language switcher on your site, please follow the instructions below:
BidJS translations (host locale)
This is built into BidJS (not a separate subscription or vendor). BidJS can
align its UI with the language of the host page by auto-detecting
the locale from the document root: it reads the lang attribute on
<html lang="..."> and listens for changes when that attribute is updated
(for example by a language switcher).
This behaviour is opt-in. Add syncHostLocale: true to window.bidjs.options.
See also
Sync with host page locale
in the Options documentation for the same setting in context.
If you drive language from your own menu or switcher, update the root element
(for example document.documentElement.setAttribute('lang', 'es')). BidJS will
follow those changes when syncHostLocale is enabled.
Use the same BCP 47 language tags that HTML expects for lang (two-letter
codes such as en, es, de, fr, or regional tags such as en-GB,
es-MX). These are web standards. Useful
public references:
- HTML
langglobal attribute (MDN) — what the attribute is for and how values are formed - BCP 47 language tag (MDN glossary)
- IANA language subtag registry — authoritative machine-readable list (advanced)
Weglot (third-party service)
Weglot is not part of BidJS; it is a separate subscription product with its own documentation and support. BidJS can work alongside it when both are embedded on your site.
When Weglot is active on your page, it takes full control of language selection and translations. This means BidJS’s automatic language switching (based on browser or host page settings, including syncHostLocale) will no longer apply.
In this setup, you should rely on Weglot to manage all languages and translated content.
We recommend setting syncHostLocale to false, or removing it from window.bidjs.options entirely when using Weglot.
Configuration
There are many options available when configuring your Weglot integration, which are all listed within the Weglot setup guides. There you will find steps to get set up that are specific to your website, however there are certain configuration options available that will ensure the best compatibility with BidJS.
Here’s an example of how your JavaScript implementation might look with our BidJS compatibility suggestions in place:
<script type='text/javascript' src='https://cdn.weglot.com/weglot.min.js' />
<script>
Weglot.initialize({
api_key: '<<YOUR_API_KEY>>',
auto_switch: true,
auto_switch_fallback: 'en',
cache: true,
dynamic: '.bidlogix-app'
});
</script>
auto_switch
This will switch the language depending on the user's browser language.
auto_switch_fallback
If setting auto_switch above, this is the language to fall back to, if the
user's language isn't supported.
cache
Setting cache to true will drastically improve the performance of Weglot on
your website, reducing the visible impact any translations may have on load
times.
dynamic
By default, Weglot performs translations on the page load. However, as BidJS is
a "Single Page Application", translations will need to be updated as the user
navigates around. By setting dynamic: '.bidlogix-app', this should be taken
care of.
Please see Weglot’s documentation for details on any further configuration options, having optimised your integration with BidJS.