Add a labels option to translate the toolbar
Closed
RO
19d ago+3195+3195+0123456789012345678901234567890123456789-2620-2620-0123456789012345678901234567890123456789
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 withshowToolbar()unless the call passestoolbar: false, and a hidden toolbar stays hidden.- English defaults live in
OverType.defaultLabels, also exported asdefaultLabels(typedDefaultLabels); itsbuttonsmap lists the built-in buttons' titles, while a button keeps its own title unlesslabelsnames it. labels.buttonsonly recognizes own keys (names liketoStringare ignored), view modes fall back to English individually, andreinitpicks up a labels object changed in place.- Dist bundles are rebuilt so npm and CDN users get
labelsand thedefaultLabelsexport.