Internationalization (i18n)
ChamevoJS UI labels can be translated to any language using the labels option.
Setting Labels
const options = {
labels: {
'toolbar.fill': 'Couleur',
'toolbar.font': 'Police',
'toolbar.remove': 'Supprimer',
'modules.text_add': 'Ajouter du texte',
'modules.images_title': 'Images',
'misc.initializing': 'Chargement...',
},
};
Label Categories
Labels use dot-notation keys organized into four categories:
| Prefix | Count | Examples |
|---|---|---|
toolbar.* | ~62 | toolbar.fill, toolbar.bold, toolbar.font_size, toolbar.remove |
actions.* | ~25 | actions.undo, actions.redo, actions.zoom_in, actions.download |
modules.* | ~81 | modules.text_add, modules.images_title, modules.layers_title |
misc.* | ~37 | misc.initializing, misc.unsaved_alert, misc.search |
See the ChamevoLabels type in @chamevo/types for the complete list.
Programmatic Usage
import { setLabels, t } from '@chamevo/core';
// Set multiple labels
setLabels({
'toolbar.fill': 'Farbe',
'toolbar.remove': 'Entfernen',
});
// Get a translated label
const label = t('toolbar.fill'); // 'Farbe'
Legacy Format
The legacy langJSON option is still supported for backward compatibility:
// Flat format
const options = {
langJSON: {
'toolbar.fill': 'Color de relleno',
},
};
// Nested format (auto-flattened)
const options = {
langJSON: {
toolbar: {
fill: 'Color de relleno',
},
},
};
The new labels option takes priority over langJSON.
Next Steps
- Configuration —
labelsandlangJSONoptions