Skip to navigation

Icons & Translations

Use these methods inside setup to register icons and translations that your plugin’s UI depends on.

registerIcon

Registers an inline SVG icon by name. Use the name in registerSource or registerFileAction.

pluginApi.registry.registerIcon({
name: 'my-icon',
svg: '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="12" cy="12" r="10" fill="currentColor"/></svg>',
});

registerL10n

Adds translation strings used by the plugin’s labels and UI.

pluginApi.registry.registerL10n({
en: {
'my-source.label': 'My Source',
'my-source.empty': 'No files found',
},
de: {
'my-source.label': 'Meine Quelle',
'my-source.empty': 'Keine Dateien gefunden',
},
});

registerL10n accepts any key. In TypeScript, declare your keys by augmenting CustomLocaleDefinition Since v1.37.0 so that your editor suggests them here and in labels. Built-in keys need no declaration:

declare module '@uploadcare/file-uploader' {
interface CustomLocaleDefinition {
'my-source.label': string;
'my-source.empty': string;
}
}

A registered key can then be used as a label.

Keys registered here can be accessed via uploaderApi.l10n('my-source.label') for translated text. The current locale name is available via pluginApi.config.get('localeName'). Labels in registerSource, registerActivity and registerFileAction are looked up the same way. See Localization for the full list of built-in keys and locale definition format.