Add a labels option to translate the toolbar

Closed
RO
19d ago
+3195-2620

Button titles by name (custom buttons too), the toolbar's accessible name and the view mode menu; anything left out stays English, shortcuts are still added, reinit({ labels }) rebuilds the toolbar. The English is OverType.defaultLabels, also exported.


Summary by cubic

Adds a labels option so the toolbar can be translated: its accessible name, the view mode menu, and any button's title by name (custom buttons too). Anything left out stays English, and a button's shortcut is still appended to its title.

  • editor.reinit({ labels }) rebuilds the toolbar; it keeps a toolbar shown with showToolbar() unless the call passes toolbar: false, and a hidden toolbar stays hidden.
  • English defaults live in OverType.defaultLabels, also exported as defaultLabels (typed DefaultLabels); its buttons map lists the built-in buttons' titles, while a button keeps its own title unless labels names it.
  • labels.buttons only recognizes own keys (names like toString are ignored), view modes fall back to English individually, and reinit picks up a labels object changed in place.
  • Dist bundles are rebuilt so npm and CDN users get labels and the defaultLabels export.