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
languageproperty to theaccessWidgetOptionsobject on thewindow.
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 theaccessWidgetinstance.
Example:
if (window.accessWidget && typeof window.accessWidget.setLanguage === 'function') {
window.accessWidget.setLanguage("fr"); // Switches to French
}