Skip to content

Languages and RTL

English and Arabic are built in. Add your own languages, change single strings, or force a direction.

On this page

Visitors switch languages from the menu in the panel's header, and the panel's direction follows the language.

Starting language

The widget starts in the visitor's last choice, otherwise in the page's html lang (so ar-EG gives Arabic, right to left), otherwise in the first language of the list. Pass language to choose it yourself, or languages: false to hide the menu.

TypeScript
import { init } from "open-accessibility-widget";

init({ language: "ar" });   // start in Arabic (right-to-left)
init({ languages: false }); // hide the language menu (English only)

Add a language

Add your own entries next to builtInLanguages. Strings missing from a language fall back to English.

TypeScript
import { init, builtInLanguages } from "open-accessibility-widget";

init({
  languages: [
    ...builtInLanguages,
    { code: "fr", name: "Français", labels: { title: "Accessibilité", resetAll: "Tout réinitialiser" } },
  ],
});

Change single strings

labels overrides strings on top of whichever language is active. increase, decrease and reset can place the setting's name with {label}; without it, the name is added at the end. Percentages are formatted for the active language.

TypeScript
init({ labels: { title: "Accessibility tools" } });

// increase, decrease and reset can place the setting's name:
init({ labels: { increase: "{label} vergrößern" } });

Direction

A custom language without dir is shown right to left when its code is a right-to-left language (ar, he, fa, ur…). dir forces one direction for every language.

TypeScript
init({ dir: "rtl" }); // force the widget's direction, whatever the language

Edit this page on GitHub