Skip to content

Language

Language

Currently, the following languages are supported:

  • English (default)
  • Norwegian
  • Dutch
  • French
  • German
  • Italian
  • Spanish
  • Finnish
  • Welsh
  • Irish Gaelic

By default, the widgets will infer the language from the user’s browser settings. If the user has an unsupported language selected for the browser, the widgets will default to English.

Set language explicitly

If you wish to set the language for the widgets explicitly, you can do so by adding the following to the configuration.

Example below shows how to set either norwegian explicitly, or having it set based on the language attribute from -tag:

<script type="text/javascript">
window.BilberryWidgetsGlobal.language = 'nb-NO'; // Set explicitly
window.BilberryWidgetsGlobal.language = document.documentElement.lang; // based on lang-attribute on html-tag
</script>

Overriding the language dynamically

If you need to change the language of the widgets dynamically, for example in order to integrate with a CMS translation tool, you can use the following JavaScript function:

For Norwegian:

window.BilberryOverrideLanguage('nb-NO');

For English:

window.BilberryOverrideLanguage('en-US');

Note! This function is only available after the page has fully loaded all remote files (after the window’s “load” event has fired).

Weglot

If using Weglot to change language in a CMS (e.g. Squarespace) you first need to explicitly set language before the scripts using this example:

window.BilberryWidgetsGlobal.language = document.documentElement.lang;

After the scripts and themes (bottom header) this can be used to change language:

<script type="text/javascript" src="https://cdn.weglot.com/weglot.min.js"></script>
<script>
Weglot.initialize({
api_key: 'XXXXXXXXXXXXXXXXXX',
});
Weglot.on('languageChanged', function (newLang, prevLang) {
let lang = newLang;
if (lang === 'no') {
lang = 'nb';
}
window.BilberryOverrideLanguage(lang);
});
</script>