accessiBe Help Center

How to set the accessWidget interface language dynamically

  • Updated

accessWidget's interface can automatically match a site’s language or respond to user-selected language changes, ideal for global audiences who expect localized, accessible experiences.

You can dynamically set accessWidget’s interface language using the config.json file in two ways:

At initialization

Great for configuring the widget’s language based on the site's logic or user geolocation.

To set the language at widget initialization

  • In your config.json file assign a language property to the accessWidgetOptions object on the window.

Example:

window.accessWidgetOptions = {
 language: "es", // Sets the widget language to Spanish
 onReady: function() {
   console.log("accessWidget API is ready");
 }
};

 

After the widget loads

Change the widget language in real-time, such as when a user changes the site language.

To set the widget language after loading

  • In your config.json file call the setLanguage() method on the accessWidget instance.

Example:

if (window.accessWidget && typeof window.accessWidget.setLanguage === 'function') {
  window.accessWidget.setLanguage("fr"); // Switches to French
}

 

 

Was this article helpful?

1 out of 1 found this helpful